2mol / pboy

a small .pdf management tool with a command-line UI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Paperboy overwrites files with duplicate names

xldenis opened this issue · comments

If you accept the name suggestion from paperboy, it will happily overwrite any files that happen to have that name in the library folder. Luckily in this case it was overwriting another copy of the same paper but it would be nice to have overwrite safeguards.

Reproduction:

  1. Create multiple copies of a pdf in Inbox folder
  2. Move them to library with the same name
  3. Watch duplicates vanish 😱.
commented

That's true, right now paperboy doesn't care, but we can definitely put in a little check. If you happen to be interested in contributing I can walk you through the code to find the right place to integrate this.

Sure! I'd be happy to add a quick feature like this.

So I've identified the place the changes need to be made, but before I go ahead with some changes, do you have an error mechanism in mind? Exceptions or ExceptT IO or ... ?

commented

Great! If you have a preference then feel free to choose. But if you are not sure, then I was thinking to change the return of

fileFile :: Config -> FilePath -> Text -> IO ()

into something like -> IO (Either FilingErr ()) so that we can display a prompt that allows to overwrite the file or cancel the action.

But that's just me keeping it stupid simple and exception free, if you have more experience with idiomatic handling of these things, then I'm happy to learn about those.

I guess the question is if we want to also catch errors about non-existing directories, file system errors and whatever else can happen. What about crazy scenarios where I manually move/delete the file while I'm renaming it. Not sure I care enough about that scenario, but it might pay off thinking about the edge cases.

@xldenis do you still work on this?

No, I completely forgot about this!! Go ahead and take over.

Unfortunately I lack the time to do so, sorry :(

commented

It will make it into a future version, no worries. I'm basically just waiting until I figure out a slightly easier way to create little popups (because we need a confirm/cancel dialog in this case). Right now with the way I do it, it's a bit annoying to create a dialog, so I have to learn more brick.

Hi I would like to work on this :)

commented

Hi I would like to work on this :)

Hi Shaurya! You're very welcome to hack on this, do you need help or do you just want to send me an initial PR with the suggested code?

Sure I can send a PR. Need to check how to handle dialog box.