pboy icon indicating copy to clipboard operation
pboy copied to clipboard

Paperboy overwrites files with duplicate names

Open xldenis opened this issue 6 years ago • 11 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 😱.

xldenis avatar Jun 19 '18 06:06 xldenis

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.

2mol avatar Jun 19 '18 11:06 2mol

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

xldenis avatar Jun 19 '18 16:06 xldenis

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 ... ?

xldenis avatar Jun 19 '18 21:06 xldenis

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.

2mol avatar Jun 20 '18 10:06 2mol

@xldenis do you still work on this?

no-identd avatar Apr 19 '19 21:04 no-identd

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

xldenis avatar Apr 22 '19 02:04 xldenis

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

no-identd avatar Apr 22 '19 11:04 no-identd

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.

2mol avatar Apr 26 '19 10:04 2mol

Hi I would like to work on this :)

sureyeaah avatar Jan 15 '20 11:01 sureyeaah

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?

2mol avatar Apr 28 '20 14:04 2mol

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

sureyeaah avatar Apr 29 '20 06:04 sureyeaah