vttc08 / movie-renamer

Rename subtitles files in directory so Jellyfin recognize it. Now with use on Linux, with OliveTin API and webtop.
MIT License
0 stars 0 forks source link

Bash script delete everything in the folder if folder path is not correct or cancelling rsync job #9

Closed vttc08 closed 7 months ago

vttc08 commented 8 months ago

In the script api.sh, when the folder path for the rsync command is invalid, the rsync command will fail. Since the script use rsync to copy and then delete the original to achieve "file moving", the files are deleted even though rsync did not copy anything.

https://github.com/vttc08/movie-renamer/blob/79e190ab7381df3431240433732ddab8c0ffbefe/api.sh#L16-L17

sending incremental file list
rsync: [Receiver] mkdir "/data/nzbget" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at main.c(791) [Receiver=3.2.7]
{"logEntry":{"datetime":"2024-03-18 01:50:17", "actionTitle":"Rename Movies", "stdout":"", "stderr":"Traceback (most recent call last):\n  File \"/home/karis/projects/movie-renamer/main.py\", line 17, in <module>\n    os.chdir(dir)\nFileNotFoundError: [Errno 2] No such file or directory: '/mnt/data/nzbget/0003 (1234)'\n", "timedOut":false, "exitCode":0, "user":"", "userClass":"", "actionIcon":"<img src = \"icons/rename-movies.png\" width=\"64px\" />", "tags":[]}}
vttc08 commented 8 months ago

To add on to the issue, the files will be deleted if the rsync job is interrupted by Ctrl-C. The action does not stop the script from running, but instead stop the current running process which is rsync and the next line of the script will run which deletes everything. The Ctrl-C is necessary to stop rsync from copying .fuse_hidden files which are files that are deleted by some software are still using it.