Check directory existence before performing operations on it

This is to support the use case where user has their own download
directory and don't use the hardcoded `/downloads` path.
Fixes #20.
This commit is contained in:
Chocobo1 2023-12-23 16:07:05 +08:00
parent 6763310101
commit 1d964be6e6
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
2 changed files with 16 additions and 8 deletions

View File

@ -28,9 +28,9 @@ if [ ! -f "$qbtConfigFile" ]; then
mkdir -p "$(dirname $qbtConfigFile)"
cat << EOF > "$qbtConfigFile"
[BitTorrent]
Session\DefaultSavePath=/downloads
Session\DefaultSavePath=$downloadsPath
Session\Port=6881
Session\TempPath=/downloads/temp
Session\TempPath=$downloadsPath/temp
[LegalNotice]
Accepted=false
@ -57,8 +57,12 @@ fi
# those are owned by root by default
# don't change existing files owner in `$downloadsPath`
chown qbtUser:qbtUser "$downloadsPath"
chown qbtUser:qbtUser -R "$profilePath"
if [ -d "$downloadsPath" ]; then
chown qbtUser:qbtUser "$downloadsPath"
fi
if [ -d "$profilePath" ]; then
chown qbtUser:qbtUser -R "$profilePath"
fi
# set umask just before starting qbt
if [ -n "$UMASK" ]; then

View File

@ -28,9 +28,9 @@ if [ ! -f "$qbtConfigFile" ]; then
mkdir -p "$(dirname $qbtConfigFile)"
cat << EOF > "$qbtConfigFile"
[BitTorrent]
Session\DefaultSavePath=/downloads
Session\DefaultSavePath=$downloadsPath
Session\Port=6881
Session\TempPath=/downloads/temp
Session\TempPath=$downloadsPath/temp
[LegalNotice]
Accepted=false
@ -57,8 +57,12 @@ fi
# those are owned by root by default
# don't change existing files owner in `$downloadsPath`
chown qbtUser:qbtUser "$downloadsPath"
chown qbtUser:qbtUser -R "$profilePath"
if [ -d "$downloadsPath" ]; then
chown qbtUser:qbtUser "$downloadsPath"
fi
if [ -d "$profilePath" ]; then
chown qbtUser:qbtUser -R "$profilePath"
fi
# set umask just before starting qbt
if [ -n "$UMASK" ]; then