Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replaceOriginalFile flow plugin doesn't work correctly after renameFile flow plugin #747

Closed
koeltv opened this issue Jan 12, 2025 · 5 comments

Comments

@koeltv
Copy link

koeltv commented Jan 12, 2025

Problem:
When using the replaceOriginalFile flow plugin after having used the renameFile flow plugin, the original file isn't replaced, instead the working file is moved to the original directory and the original file is removed.

Solution:

const currentPath = args.inputFileObj._id;
const orignalFolder = getFileAbosluteDir(args.originalLibraryFile._id);
const fileName = getFileName(args.inputFileObj._id);
const container = getContainer(args.inputFileObj._id);
const newPath = `${orignalFolder}/${fileName}.${container}`;
const newPathTmp = `${newPath}.tmp`;

The plugin uses the filename of the working file to set the newPath, it should instead use the filename of the original file:

 const currentPath = args.inputFileObj._id; 
 const originalFolder = getFileAbsoluteDir(args.originalLibraryFile._id); 
 const fileName = getFileName(args.originalLibraryFile._id); 
 const container = getContainer(args.inputFileObj._id); 
  
 const newPath = `${originalFolder}/${fileName}.${container}`; 
 const newPathTmp = `${newPath}.tmp`; 

Maybe this could be an option to keep the working file or original file filename

@supersnellehenk
Copy link
Collaborator

So what is wrong here?

You're renaming the original file, then calling "replace original file", which will indeed move the temp file over, then delete the original and remove the .tmp from the moved working file.

If you want to keep both, you'd have to use Move To Directory instead.

@koeltv
Copy link
Author

koeltv commented Jan 12, 2025

The reason I have this issue is that to test my own flow, after processing the video file I rename it to ${filename} - Transcoded.${container} so that I can do a visual comparison through Jellyfin and click on "Reviewed" to replace the original after.
In this case, since I renamed it for testing purposes, when I use replaceOriginalFile it doesn't change the name back to the original filename.

@supersnellehenk
Copy link
Collaborator

Well, you'd have to rename your file back after that. That's not what replaceOriginalFile is intended for

@koeltv
Copy link
Author

koeltv commented Jan 12, 2025

Oh okay, would it be possible to put more details about it in the description of replaceOriginalFile to explain that the working file filename and container will be used ? Although it is quite logical for the container, for the filename I believe it is less so.

HaveAGitGat added a commit that referenced this issue Jan 26, 2025
HaveAGitGat added a commit that referenced this issue Jan 26, 2025
@HaveAGitGat
Copy link
Owner

Updated #756

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants