--conflict override not working?

All your suggestions, requests and ideas for future development
Post Reply
verysofttoiletpaper
Posts: 141
Joined: 05 Jul 2012, 09:44

--conflict override not working?

Post by verysofttoiletpaper »

Hi, isn't --conflict override supposed to replace existing symlinks if they exist?

Code: Select all

SYMLINK] Failed to rename [/mnt/media/Media/Deluge/downloads/The.Big.Bang.Theory.S06E24.The.Bon.Voyage.Reaction.576p.WEB-DL.DD5.1.x264-RKH.mkv]
FileAlreadyExistsException: /mnt/media/Media/TV Shows/The Big Bang Theory/Season 06/The Big Bang Theory - S06E24 - The Bon Voyage Reaction.mkv
Thanks
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: --conflict override not working?

Post by rednoah »

Works on Windows. Maybe there's some strange behaviour with symlinks on *nix.

EDIT: Tested on Ubuntu and also works.
:idea: Please read the FAQ and How to Request Help.
verysofttoiletpaper
Posts: 141
Joined: 05 Jul 2012, 09:44

Re: --conflict override not working?

Post by verysofttoiletpaper »

rednoah wrote:Works on Windows. Maybe there's some strange behaviour with symlinks on *nix.

EDIT: Tested on Ubuntu and also works.
It is on ubuntu I'm running it..
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: --conflict override not working?

Post by rednoah »

But if you do COPY or KEEPLINK it works?
:idea: Please read the FAQ and How to Request Help.
verysofttoiletpaper
Posts: 141
Joined: 05 Jul 2012, 09:44

Re: --conflict override not working?

Post by verysofttoiletpaper »

No, they act like --conflict skip and end with success:

Code: Select all

Skipped [/mnt/media/Media/Movies/The Karate Kid (1984)/The Karate Kid (1984).mkv] because [/mnt/media/Media/Movies/The Karate Kid (1984)/The Karate Kid (1984).mkv] already exists
Symlink only skips if the second file is different from the file which the current link is pointing to. If the file being processed is the one the extisting link is already pointing to, it doesn't do anything, doesn't say "skipping", nor "error", it just completes successfully.

I'm running FileBot 3.5 (r1546) / Java(TM) SE Runtime Environment 1.7.0_21 (headless)
Isn't supposed 3.6 to be in the ubuntu repos already?

Thanks
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: --conflict override not working?

Post by rednoah »

Works as expected any way I tried:

Code: Select all

reinhard@serenity:~/test$ filebot -rename . --format "./output/{movie}" --db themoviedb --action symlink
Rename movies using [TheMovieDB]
Auto-detect movie from context: [/home/reinhard/test/The Karate Kid (1984).mkv]
[SYMLINK] Rename [/home/reinhard/test/The Karate Kid (1984).mkv] to [./output/The Karate Kid (1984).mkv]
Processed 1 files
Done ヾ(@⌒ー⌒@)ノ

reinhard@serenity:~/test$ filebot -rename . --format "./output/{movie}" --db themoviedb --action symlink
Rename movies using [TheMovieDB]
Auto-detect movie from context: [/home/reinhard/test/The Karate Kid (1984).mkv]
Skipped [/home/reinhard/test/The Karate Kid (1984).mkv] because [/home/reinhard/test/./output/The Karate Kid (1984).mkv] already exists
Processed 1 files
Done ヾ(@⌒ー⌒@)ノ

reinhard@serenity:~/test$ filebot -rename . --format "./output/{movie}" --db themoviedb --action symlink --conflict override
Rename movies using [TheMovieDB]
Auto-detect movie from context: [/home/reinhard/test/The Karate Kid (1984).mkv]
[SYMLINK] Rename [/home/reinhard/test/The Karate Kid (1984).mkv] to [./output/The Karate Kid (1984).mkv]
Processed 1 files
Done ヾ(@⌒ー⌒@)ノ
:idea: Please read the FAQ and How to Request Help.
verysofttoiletpaper
Posts: 141
Joined: 05 Jul 2012, 09:44

Re: --conflict override not working?

Post by verysofttoiletpaper »

Have you tried the following in the same folder?

Code: Select all

filebot -rename . --format "./output/{movie}" --db themoviedb --action symlink

mv "The Karate Kid (1984).mkv" "The_Karate_Kid_(1984).mkv"

filebot -rename . --format "./output/{movie}" --db themoviedb --action symlink --conflict override
Thanks
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: --conflict override not working?

Post by rednoah »

This use-case has an issue. Cause you end up handling to identical movies that resolve to idential paths. The --action override just deletes the original symlink. But then the previous symlink gets symlinked. That works. But then the renamed file gets also symlinked to that path and it already exists.

I probably should add some sanity checks before-hand but i'll still make it abort.

EDIT:
Nevermind that. In anycase Java 6 File.exists() returns false for broken links. I can fix it only by using Java 7 NIO.2 classes but then I break backwards compatibility...

EDIT2:
Decided not to fix this. I'd broken behaviour by Java 7 as it's different from Java 6 (which doesn't understand symlinks and thus works correctly). Once I give up supporting Java 6 I can fix it easily.

In the meanwhile you can just make sure that there's no broken symlinks on folders you run filebot on:
http://www.commandlinefu.com/commands/v ... elete-them
:idea: Please read the FAQ and How to Request Help.
verysofttoiletpaper
Posts: 141
Joined: 05 Jul 2012, 09:44

Re: --conflict override not working?

Post by verysofttoiletpaper »

rednoah wrote:This use-case has an issue. Cause you end up handling to identical movies that resolve to idential paths. The --action override just deletes the original symlink. But then the previous symlink gets symlinked. That works. But then the renamed file gets also symlinked to that path and it already exists.

I probably should add some sanity checks before-hand but i'll still make it abort.

EDIT:
Nevermind that. In anycase Java 6 File.exists() returns false for broken links. I can fix it only by using Java 7 NIO.2 classes but then I break backwards compatibility...

EDIT2:
Decided not to fix this. I'd broken behaviour by Java 7 as it's different from Java 6 (which doesn't understand symlinks and thus works correctly). Once I give up supporting Java 6 I can fix it easily.

In the meanwhile you can just make sure that there's no broken symlinks on folders you run filebot on:
http://www.commandlinefu.com/commands/v ... elete-them
I'm not sure what you mean with "But then the previous symlink gets symlinked". Does the following use case solve the problem you are talking about?

Code: Select all

filebot -rename "The Karate Kid (1984).mkv" --format "./output/{movie}" --db themoviedb --action symlink

mv "The Karate Kid (1984).mkv" "The_Karate_Kid_(1984).mkv"

filebot -rename "The_Karate_Kid_(1984).mkv" --format "./output/{movie}" --db themoviedb --action symlink --conflict override
Thanks
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: --conflict override not working?

Post by rednoah »

Ignore what I said before the edits. :P

The problem is that I check if files already exist with File.exists() and then delete it if it does, except Java 7 says "does not exist" if called on a symlink as the target file doesn't exist. So my code doesn't try to delete the symlink cause it thinks it doesn't exist.

I can only fix this by using new Java 7 APIs where I can specifically tell the Files.exists() method to not follow symlinks.
:idea: Please read the FAQ and How to Request Help.
verysofttoiletpaper
Posts: 141
Joined: 05 Jul 2012, 09:44

Re: --conflict override not working?

Post by verysofttoiletpaper »

rednoah wrote:Ignore what I said before the edits. :P

The problem is that I check if files already exist with File.exists() and then delete it if it does, except Java 7 says "does not exist" if called on a symlink as the target file doesn't exist. So my code doesn't try to delete the symlink cause it thinks it doesn't exist.

I can only fix this by using new Java 7 APIs where I can specifically tell the Files.exists() method to not follow symlinks.

Ahh that makes sense :)
Thanks for the great support once again!
Post Reply