Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need fallback behaviour when dirs::download_dir returns None #118

Closed
netzego opened this issue Jun 8, 2023 · 5 comments
Closed

Need fallback behaviour when dirs::download_dir returns None #118

netzego opened this issue Jun 8, 2023 · 5 comments
Milestone

Comments

@netzego
Copy link

netzego commented Jun 8, 2023

% iamb
thread 'main' panicked at 'no dirs.downloads value configured!', src/config.rs:327:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
% uname -a
Linux sao 6.1.31-hardened1-1-hardened #1 SMP PREEMPT_DYNAMIC Thu, 01 Jun 2023 22:45:12 +0000 x86_64 GNU/Linux
% rustc --version
rustc 1.70.0 (90c541806 2023-05-31) (Arch Linux rust 1:1.70.0-1)
% iamb --version
iamb 0.0.7

Hope that enough info? If not let me know. Thx for your time <3

@balejk
Copy link
Contributor

balejk commented Jun 11, 2023

You can solve this by setting it in your config like this:

{
	"profiles": {
        ...
	},
	"dirs": {
		"downloads": "/some/path"
	}
}

or by exporting the environment variable XDG_DOWNLOAD_DIR (see here).

@netzego
Copy link
Author

netzego commented Jun 14, 2023

@balejk thx! Indeed, this does the trick. According to https://www.freedesktop.org/wiki/Software/xdg-user-dirs/ $XDG_DOWNLOAD_DIR should default to $HOME.

Here is a shellscript example of how to find the desktop and the download directory:
echo ${XDG_DOWNLOAD_DIR:-$HOME}

There is an open issue from the dirs crate: xdg-rs/dirs#56.

Edit: Linked the wrong crate 😹

@netzego
Copy link
Author

netzego commented Jun 15, 2023

I opened an issue here: dirs-dev/dirs-rs#50. But not sure if the default value should be implemented by the dirs-rs crate or handled by the software which pulls it in?

@benjajaja
Copy link
Contributor

This should be handled somehow, the least effort would be to make it optional (and then just never download anything).

@ulyssa ulyssa added this to the v0.0.8 milestone Jul 7, 2023
@ulyssa ulyssa changed the title Got this error: [...] no dirs.downloads value configured [...] after building Need fallback behaviour when dirs::download_dir returns None Jul 8, 2023
@ulyssa
Copy link
Owner

ulyssa commented Jul 8, 2023

I've implemented this the way @benjajaja described, and made it optional with an error message displayed after startup when you try to download a file without either specifying a path or a downloads directory.

@ulyssa ulyssa closed this as completed Jul 8, 2023
@ulyssa ulyssa mentioned this issue Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants