Closed Heavybullets8 closed 1 month ago
Let me look this over and I'll get back to you. Might be a bit due to life being what it is right now.
No problem at all! Hope things are going well. If you need anything lmk brother.
Also if you need to checkout my test env (well actually its in prod) its in my kubernetes repo: https://github.com/Heavybullets8/heavy-ops/blob/main/kubernetes/apps/media/plex/daps/overwrite/poster_renamerr.py https://github.com/Heavybullets8/heavy-ops/blob/main/kubernetes/apps/media/plex/daps/config/config.yaml
If anything needs to be changed to a specific style or anything just lmk or make the changes yourself if you would prefer. Cheers man.
Use
os.path.lexists()
Instead ofos.path.isfile()
:os.path.isfile()
returnsFalse
for broken symlinks. Switching toos.path.lexists()
ensures that both existing files and symlinks (including broken ones) returnTrue
.Remove Existing Files Before Creating Links:
os.link()
oros.symlink()
, the script now checks if the target path exists usingos.path.lexists()
. If it does, and the action is to create a symlink or hardlink, the existing file is removed sinceos.symlink()
andos.link()
do not overwrite destination files.Handle Broken Symlinks:
try
block. If a broken symlink is encountered (raising aFileNotFoundError
), the script removes it so the new link can be made.Testing
Tested the updated script on my machine, which resolved the issue where new posters were not replacing existing ones due to existing files. Hopefully these changes can get us closer to having support for
symlink
andhardlink
action types.