PlexCache icon indicating copy to clipboard operation
PlexCache copied to clipboard

Error: [Errno 2] No such file or directory. Files exist can touch and ls.

Open DuzAwe opened this issue 2 years ago • 47 comments

I am getting the bellow. Very confused as I can see the files. Running on Unraid

`root@TheLibrary:/mnt/user/scripts/PlexCache# python3 plexcache.py *** PlexCache *** Debug mode is active, NO FILE WILL BE MOVED. Fetching DuzAwe's onDeck media... Editing file paths... Fetching subtitles... Fetching watched media... Fetching DuzAwe's watched media... Editing file paths... Fetching subtitles... Nothing to move to array Error: [Errno 2] No such file or directory: "/mnt/user/TV/It's Always Sunny in Philadelphia (2005) [TVdb-75805]/Season 13/It's.Always.Sunny.in.Philadelphia.-.S13E03.-.The.Gang.Beats.Boggs-.Ladies.Reboot.WEBDL-1080p.mkv" root@TheLibrary:/mnt/user/scripts/PlexCache# nano plexcache_settings.json root@TheLibrary:/mnt/user/scripts/PlexCache# python3 plexcache.py *** PlexCache *** Fetching DuzAwe's onDeck media... Editing file paths... Fetching subtitles... Loading watched media from cache... Nothing to move to array Error: [Errno 2] No such file or directory: "/mnt/user/TV/It's Always Sunny in Philadelphia (2005) [TVdb-75805]/Season 13/It's.Always.Sunny.in.Philadelphia.-.S13E03.-.The.Gang.Beats.Boggs-.Ladies.Reboot.WEBDL-1080p.mkv" root@TheLibrary:/mnt/user/scripts/PlexCache# ^C root@TheLibrary:/mnt/user/scripts/PlexCache# ^C root@TheLibrary:/mnt/user/scripts/PlexCache# ls /mnt/user/TV/It's Always Sunny in Philadelphia (2005) [TVdb-75805]/Season 13/

^C root@TheLibrary:/mnt/user/scripts/PlexCache# python3 plexcache.py *** PlexCache *** Fetching DuzAwe's onDeck media... Editing file paths... Fetching subtitles... Loading watched media from cache... Nothing to move to array Error: [Errno 2] No such file or directory: '/mnt/user/TV/Star Trek - Strange New Worlds (2022) [TVdb-382389]/Season 02/Star.Trek-.Strange.New.Worlds.-.S02E07.-.Those.Old.Scientists.WEBDL-2160p.mkv'`

DuzAwe avatar Jul 27 '23 21:07 DuzAwe

Would you mind sending the log file instead?

bexem avatar Jul 27 '23 23:07 bexem

Thank you for the logs file! I had a first look and it doesn't seem you have any misconfiguration, and the script does seem to be working with other files, correct? I am not saying there is no issue with the script, but I can't seem to find the culprit at the moment that could explain why that specific file(s) doesn't exist for the script. The only things it comes up are permissions of those files, even though I thought the script would run as root in unraid? Just to rule it out, would you mind checking the permissions of the file that are giving you issues? Also check the permissions of the files (possibly even of the same show) that are actually working fine. ls -l

I will be able to pay more attention to this issue at the beginning of the week, I'm currently in between night shifts and my free time (and brain power) is limited.

bexem avatar Jul 28 '23 15:07 bexem

It does not appear to be move any files

Last login: Thu Jul 27 22:09:54 2023 from 192.168.0.46
Linux 6.1.38-Unraid.
root@TheLibrary:~# cd /mnt/user/scripts/PlexCache
root@TheLibrary:/mnt/user/scripts/PlexCache# ls -l
total 4325
-rw-rw-rw- 1 root root    3307 Jul 27 21:55 README.md
-rw-rw-rw- 1 root root   64589 Jul 27 22:29 plexcache.py
-rw-rw-rw- 1 root root 3642057 Jul 27 22:32 plexcache_log_20230727_2231.log
-rw-rw-rw- 1 root root  239363 Jul 27 22:36 plexcache_log_20230727_2235.log
-rw-rw-rw- 1 root root  108179 Jul 27 22:36 plexcache_log_20230727_2236.log
-rw-rw-rw- 1 root root  104966 Jul 27 22:41 plexcache_log_20230727_2241.log
lrwxrwxrwx 1 root root      59 Jul 27 22:41 plexcache_log_latest.log -> /mnt/user/scripts/PlexCache/plexcache_log_20230727_2241.log
-rw-rw-rw- 1 root root     778 Jul 27 22:41 plexcache_settings.json
-rw-rw-rw- 1 root root   18264 Jul 27 21:55 plexcache_setup.py
-rw-rw-rw- 1 root root   85346 Jul 27 22:36 plexcache_watched_cache.json
-rw-rw-rw- 1 root root      16 Jul 27 21:55 requirements.txt
root@TheLibrary:/mnt/user/scripts/PlexCache# ls
README.md                        plexcache_log_20230727_2236.log  plexcache_setup.py
plexcache.py                     plexcache_log_20230727_2241.log  plexcache_watched_cache.json
plexcache_log_20230727_2231.log  plexcache_log_latest.log@        requirements.txt
plexcache_log_20230727_2235.log  plexcache_settings.json
root@TheLibrary:/mnt/user/scripts/PlexCache# nano plexcache_settings.json
root@TheLibrary:/mnt/user/scripts/PlexCache# cd /mnt/ingress/
root@TheLibrary:/mnt/ingress# ls -l
total 16
drwxrwxrwx 4 nobody users 4 Jul 24 14:32 Back\ Up/
drwxrwxrwx 3 nobody users 3 Jul 28 05:44 Movies/
drwxrwxrwx 9 nobody users 9 Jul 26 11:17 TV/
drwxrwxrwx 5 nobody users 5 Jul 27 21:55 scripts/
root@TheLibrary:/mnt/ingress# cd TV/
root@TheLibrary:/mnt/ingress/TV# ls -l
total 7
drwxrwxrwx 3 nobody users 3 May 21 19:07 Foundation\ (2021)\ [tvdb-366972]/
drwxrwxrwx 3 nobody users 3 Jul 28 01:24 Good\ Omens\ (2019)\ [tvdb-359569]/
drwxrwxrwx 3 nobody users 3 May 22 07:12 Harley\ Quinn\ (2019)\ [tvdb-365677]/
drwxrwxrwx 3 nobody users 3 Jul 27 21:04 Looney\ Tunes\ Cartoons\ (2020)\ [tvdb-380849]/
drwxrwxrwx 3 nobody users 3 May 21 19:08 Love,\ Death\ &\ Robots\ (2019)\ [tvdb-357888]/
drwxrwxrwx 3 nobody users 3 Jun 18 00:59 What\ We\ Do\ in\ the\ Shadows\ (2019)\ [tvdb-358211]/
drwxrwxrwx 3 nobody users 3 Jul  3 03:54 Witcher,\ The\ (2019)\ [tvdb-362696]/
root@TheLibrary:/mnt/ingress/TV#


DuzAwe avatar Jul 28 '23 15:07 DuzAwe

Also don't worry about it. I assume your NHS, don't be stressing about hobby bugs

DuzAwe avatar Jul 28 '23 15:07 DuzAwe

Also don't worry about it. I assume your NHS, don't be stressing about hobby bugs

Guilty! I've updated the script ever so slightly:

  • The script will not exit while in debug and encountering an issue during file 'movement', hopefully it will make it easier to understand where the issue is.
  • Introduced a fixed list of subtitles extensions, as I noticed from your log it was moving the .nfo files as well as the media.

That is probably it for today.

Also...thank you so so much! ❤️

bexem avatar Jul 28 '23 15:07 bexem

Afraid, It still thinks the file doesn't exist. It's hardly as straight forward as it not escaping the ( ) or [ ].

So the behaviour is the same, It trys the first file and doesn't progress. I git pulled before I ran.

plexcache_log_20230728_1712.log plexcache_log_latest.log

DuzAwe avatar Jul 28 '23 16:07 DuzAwe

So as far I understood the file /mnt/user/TV/Star Wars - The Clone Wars (2008) [TVdb-83268]/Season 05/Star.Wars-.The.Clone.Wars.-.S05E17.-.Sabotage.Bluray-1080p.mkv does exist in your system. Is it present in the user0 folder or in the cache?

My bad about the exiting, I forgot that logging.critical also halt the script, now it should not stop according to the logic. I've also quickly added another check when calculating the free space. It still doesn't fix the issue, but I'm trying to understand what's going on in you case.

Time to go for real this time!

bexem avatar Jul 28 '23 16:07 bexem

It would be in the user. /mnt/user/TV.

cache is a practically empty zpool can confirm the script moves nothing to it.

DuzAwe avatar Jul 28 '23 20:07 DuzAwe

plexcache_log_latest.log Screenshot 2023-07-28 211925 Screenshot 2023-07-28 211937

First file fails, doesn't try the rest. All the files exist on the array under user.

DuzAwe avatar Jul 28 '23 20:07 DuzAwe

I don't think I'm gonna be able to do much today or tomorrow but I'm actively thinking on how to solve this issue.

When the debug mode is off, the script is designed to exit in case it encounters an error during the moving process. I've removed this logic in this version of the file plexache. My idea is to let the script move at least some files to see if there is any underlying issue I'm/We're not seeing and could lead to a solution. Perhaps might be better to set the script to copy only the minimum necessary files and have a backup of the data, just in case the script accidentally corrupts any files. It is unlikely but it's always better to be safe than sorry.

I find it odd that some other users, including myself (though I may be biased), use the script without any issues. I'm thinking openly, and the only difference I can think of is the zpool. However, I cannot confirm this since I don't know the exact setup of other users, so they might actually use one already. Regardless, whether using zpool or not, it should be completely transparent to the script and shouldn't matter at all, that's why I'm not focusing on this but I just wanted to share this intrusive thought.

bexem avatar Jul 29 '23 14:07 bexem

plexcache_log_latest.log

Well-aware coding is 99% in the brain, not the computer. Ran the new file same result. To test that theory you have I've run the script with it pointing at a disk on the array rather than the cache. Still wouldn't work, however I removed the () and [] from two of the directory and they no longer trigger the error....but there does seem to be an issue with the zpool.

See attached when going to disk13 (xfs) it appears to work with an estimated move size. With the target being ingress (zpool) It tells me there are no files to move.

brackets.removed.debug.to.zpool.log brackets.removed.debug.to.disk.log

DuzAwe avatar Jul 29 '23 21:07 DuzAwe

Good morning!

Thank you for the testing! It made me think a bit. Apparently I have to properly handle zpools with the script, so I have to test if any of the sources and/or destination are zpools and act accordingly. This will take a few hours and testing, unfortunately, I will work blind on it because I have no zpool in my Unraid system. So I beg for your patience.

Regarding the parenthesis, well, now I've wrapped the folder/file name properly, so it should not give any more issues.

I will work on it between later tonight or tomorrow. Now that I have a potential solution in my mind, I'm quite excited to see how it turns out and improve the script further. I'll keep you updated on my progress!

bexem avatar Jul 30 '23 05:07 bexem

So I've made some edits but I cannot test it so I'm not sure it will work: The script now checks the file system of the source and destination and uses "zfs clone" and "zfs destroy" to move files around. It will also calculate the free space accordingly as zfs also handle that differently.

Please let me know if it works at all!

Forgot to say, this is the new version: zfs

bexem avatar Jul 31 '23 16:07 bexem

Ran it, No logs were produced. Still getting the file error.

Error: [Errno 2] No such file or directory: '/mnt/user/TV/Star Wars - The Clone Wars (2008) [TVdb-83268]/Season 06/Star.Wars-.The.Clone.Wars.-.S06E01.-.The.Unknown.Bluray-1080p.mkv' Execution time of the script: 15 seconds

DuzAwe avatar Jul 31 '23 16:07 DuzAwe

Will "zfs clone" and "zfs destroy" work of the array is XFS?

DuzAwe avatar Jul 31 '23 16:07 DuzAwe

Ran it, No logs were produced. Still getting the file error.

Error: [Errno 2] No such file or directory: '/mnt/user/TV/Star Wars - The Clone Wars (2008) [TVdb-83268]/Season 06/Star.Wars-.The.Clone.Wars.-.S06E01.-.The.Unknown.Bluray-1080p.mkv' Execution time of the script: 15 seconds

I can't understand why the script hasn't written the log file, I did not touch that at all, and even in the event of an error during the zfs operation, it will still produce a log entry, also I can see it did end the reach as it printed the execution time, which is only invoked at the end of the script. Just odd. I've added a few extra logging info to locate exactly where the error happens.

Will "zfs clone" and "zfs destroy" work of the array is XFS?

The script will use the zfs clone and destroy commands only when the file system is ZFS, otherwise it will use 'normal' commands for moving files.

bexem avatar Jul 31 '23 17:07 bexem

Before running the last updated version, please install psutil (pip install psutil) because I'm using that to check for the free space as it is more system agnostic and should work on ZFS too.

bexem avatar Jul 31 '23 17:07 bexem

Syntax error and my pythons not good enough to figure it out :P

:/mnt/user/scripts/PlexCache# python3 plexcache_zfs.py
  File "/mnt/user/scripts/PlexCache/plexcache_zfs.py", line 1144
    if check_path_exists(user_path)
                                   ^
SyntaxError: invalid syntax

DuzAwe avatar Aug 01 '23 08:08 DuzAwe

Sorry if I took so long to actually answer. My bathroom decided was a good time to leak some water.

Either way I have no idea what the hell happened in my code, it was spamming me with a very generic module error even though I did test it. I've now basically rewritten the zfs logic from scratch, tested the script and it works, but as usual, I cannot confirm the zfs logic actually works.

Thank you for your patience!

bexem avatar Aug 01 '23 18:08 bexem

Absolutely no worries, I have zen practice on Mondays so I was limited in my ability to test anything.

On Tue 1 Aug 2023 at 19:39, Emanuele B. @.***> wrote:

Sorry if I took so long to actually answer. My bathroom decided was a good time to leak some water.

Either way I have no idea what the hell happened in my code, it was spamming me with a very generic module error even though I did test it. I've now basically rewritten the zfs logic from scratch, tested the script and it works, but as usual, I cannot confirm the zfs logic actually works.

Thank you for your patience!

— Reply to this email directly, view it on GitHub https://github.com/bexem/PlexCache/issues/18#issuecomment-1660881075, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVOY6JEUZPHG2KIAYTN7GLXTFEPRANCNFSM6AAAAAA22VMGOQ . You are receiving this because you authored the thread.Message ID: @.***>

DuzAwe avatar Aug 01 '23 18:08 DuzAwe

Still no logs

Fetching subtitles...
Nothing to move to array
Error: [Errno 2] No such file or directory: '/mnt/user/TV/Star Wars - The Clone Wars (2008) [TVdb-83268]/Season 06/Star.Wars-.The.Clone.Wars.-.S06E02.-.Conspiracy.Bluray-1080p.mkv'

DuzAwe avatar Aug 01 '23 20:08 DuzAwe

So no log at all? Like not even interrupted? I get having the error, but it would still start logging at the beginning way before interacting with the new zfs logic, and even if it return an error, the script will still continue as I've put no exits on purpose.

bexem avatar Aug 01 '23 20:08 bexem

No logs from either script or branch? This is new. Otherwise still chocking don't the file verbose-output.txt

DuzAwe avatar Aug 01 '23 20:08 DuzAwe

That is so odd. So I guess if you run plexcache_exclude_file.py the log will work? The only difference between the zfs one is exactly the zfs logic, otherwise is line by line identical. If this is the case then it means the zfs logic does make the whole thing crash (but why delete the log file? That is just weird).

bexem avatar Aug 01 '23 20:08 bexem

No log from that either, nor when I switch back to main....odd there where logs. All the permissions are nobody and the scripts are root.

DuzAwe avatar Aug 01 '23 21:08 DuzAwe

So you are not getting any logs at all? Have you tried setting another folder for the logs? It's weird that it just stopped working for you, but I can't see the issue lying in the script to be fully honest with you. Not that it matters, I will keep trying to help anyway.

script_folder = "/mnt/user/system/plexcache/" # Folder path for the PlexCache script storing the settings, watchlist & watched cache files
logs_folder = script_folder # Change this if you want your logs in a different folder

bexem avatar Aug 01 '23 21:08 bexem

. plexcache_log_latest.log .......Looking in the wrong folder. Here are the logs.

DuzAwe avatar Aug 01 '23 22:08 DuzAwe

It happens, at least is sorted! Just to be sure that is the log for the latest zfs script? If you don't mind getting the latest version (just pushed), try it and send the log again?

bexem avatar Aug 01 '23 22:08 bexem

Most recent run from the most recent push. plexcache_log_latest.log

DuzAwe avatar Aug 02 '23 08:08 DuzAwe