Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

qBittorrent saves new torrents to /config/qBittorrent/downloads by default #91

Closed
DyonR opened this issue Feb 16, 2022 · 0 comments
Closed

Comments

@DyonR
Copy link
Owner

DyonR commented Feb 16, 2022

This issues was raised to me on the Unraid forums

qBittorrent changed the configuration names of certains settings in, I believe this commit: qbittorrent/qBittorrent@dd1bd8a

For an unknown reason, the configuration files of this Docker didn't upgrade with this new version, resulting in qBittorrent setting the save location of new torrents to /config/qBittorrent/downloads.

How to fix manually

  1. Open the Web Interface of qBittorent
  2. Click on the settings/gear icon
  3. At the Downloads tab in the "Saving Management" section, set the Default Save Path to /downloads, if desired, check the box Keep incomplete torrents in: and set this path to /downloads/temp
  4. Scroll down, and save.
  5. Restart the Docker container, just to be sure the new settings got saved.
  6. In the torrent list, right click on any of the columns like Name, Size, Done, Status, etc and add the new column named Save path (scrolling is probably necessary for it to show up).
  7. Sort all your torrents by clicking on the 'Save path'
  8. Select all torrents that match the Save path (CTRL+SHIFT+Click works) /config/qBittorrent/downloads
  9. Right click any of the selected torrents and select Set location, set it to /downloads and click Save.

I am not fixing this through a container update

I will not fix this through a container update because I do not want to mess with the .fastresume (the file that stores the progress information, save location and a lot more about the individiual torrents in qBittorrent).

The code below was supposed to be a new section in the qbittorrent/start.sh file, but I decided not to work on it further.

Problems;
1a. It doesn't check if the user already fixed it themselves.
1b. It doesn't check the [BitTorrent] section in the config file to see if the new Session\DefaultSavePath etc already exist, so it keeps adding it on every reboot.
2. Moving the files is a dirty fix.
3. Messing with the .fastresume files is tricky. What if someone has a rule to automatically move it to a sub-directory? In that case the .fastresume file would be different than the default savePath29 / save_path29.

export CORRECT_SAVEPATH=$(echo "${CORRECT_SAVEPATH,,}")
if [[ ! -z "${CORRECT_SAVEPATH}" ]]; then
    echo "[WARNING] CORRECT_SAVEPATH is not set. Switching this to 'yes' to fix the config. Set to 'no' if you do not want this Docker to mess with your SavePath config." | ts '%Y-%m-%d %H:%M:%.S'
    export CORRECT_SAVEPATH="yes"
fi

if [[ ${CORRECT_SAVEPATH} == 'yes' ]]; then
    # Getting the current TempPathValue value
    TEMPPATHVALUE=$(sed -n '/\[Preferences]/,$p' '/config/qBittorrent/config/qBittorrent.conf' | grep -i "TempPathEnabled" | sed 's/^.*=//')
    # Removing the old lines
    sed -i '/Downloads\\SavePath=\/downloads\/\|Downloads\\TempPath=\/downloads\/temp\/\|Downloads\\TempPathEnabled=*/d' "/config/qBittorrent/config/qBittorrent.conf"
    # Insert the new lines at the correct section
    sed -i "/^\[BitTorrent]/a Session\\DefaultSavePath=\/downloads\nSession\\TempPath=\/downloads\/temp\nSession\\TempPathEnabled=${TEMPPATHVALUE}" "/config/qBittorrent/config/qBittorrent.conf"
    cp -r /config/qBittorrent/downloads/* /downloads -vvvv && rm -rf /config/qBittorrent/downloads -vvvv
    for fastresumefile in /config/qBittorrent/data/BT_backup/*.fastresume
    do
        echo "Processing fastrume file $fastresumefile"
        sed -i 's/savePath29\:\/config\/qBittorrent\/downloads/savePath10\:\/downloads/g' "$fastresumefile"
        sed -i 's/savePath29\:\/config\/qBittorrent\/downloads/savePath10\:\/downloads/g' "$fastresumefile"
    done
else
    echo "[WARNING] You have set CORRECT_SAVEPATH as: '${CORRECT_SAVEPATH}'. Please check the qBittorrent settings to make sure your save paths are corrent!" | ts '%Y-%m-%d %H:%M:%.S'
fi
@DyonR DyonR pinned this issue Feb 16, 2022
@DyonR DyonR closed this as completed Feb 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant