lehitoskin / ivy

Ivy, the Taggable Image Viewer
GNU General Public License v3.0
16 stars 3 forks source link

Allow `-M` (move) option to rename a file. #70

Closed IonoclastBrigham closed 6 years ago

IonoclastBrigham commented 6 years ago

In the case where a single image file is specified as the source argument to -M, allow the destination to be a desired file name. The actual function being used, (rename-file-or-directory old new), allows this without modification.

This enhancement request doesn't take a strong stance on correct default behavior if the destination file already exists; probably it should just do whatever ivy already does if you tried to move "foo.jpg" into a directory that already had a file with that name.

lehitoskin commented 6 years ago

This is already what happens. I tried to copy the behavior of the mv command line tool so that it would feel more natural while in the terminal.

The actual function being used, (rename-file-or-directory old new), allows this without modification.

I don't get what you're trying to say.

That being said, as I take a closer look at the relevant code I realize it could benefit from a little modification. As it currently stands, even if dest exists on the filesystem while source does not exist on the filesystem (yet both are in the database), the tags in the database will be reconciled and then it'll fail once it gets to rename-file-or-directory, which seems like poor behavior. From my viewpoint, this operation should fail early if either source does not exist on the filesystem or dest does exist on the filesystem.