Rockbox

Tasklist

FS#9864 - When cutting and pasting, overwriting doesn't work

Attached to Project: Rockbox
Opened by Boris Gjenero (dreamlayers) - Monday, 02 February 2009, 20:38 GMT
Task Type Bugs
Category Operating System/Drivers
Status Unconfirmed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No

Details

When moving files or directories by cutting and pasting, if the destination exists I am asked if I want to overwrite. If I say yes, the operation fails. This is because the rename fails because the destination exists. Copying and pasting works properly.

The attached patch fixes the problem by deleting the target if it exists just before the rename. (At this point the user has already agreed to overwrite the target.)

This was tested with r19907 on my 30GB 5G iPod. It should not depend on the player type.
This task depends upon

Comment by Nils Wallménius (nls) - Wednesday, 04 February 2009, 13:09 GMT
Hi, I was unable to reproduce this in a sim.
Could you please add some instructions for how to reproduce?
Comment by Boris Gjenero (dreamlayers) - Wednesday, 04 February 2009, 16:33 GMT
To see the issue when pasting files, have the following:
/file
/directory/file
Hold select on /file, cut. Go into /dir, hold select, paste and confirm that you want to overwrite by pressing select. You'll get "Paste failed".

To see the issue when pasting directories, have:
/dira/file
/dirb/dira/file
Hold select on /dira, cut. Go into /dirb, hold select, paste and confirm that you want to overwrite by pressing select. Again "Paste failed".

In the file case, both my iPod and the sim ask if I want to overwrite. In the directory case, my iPod asks but the sim doesn't. If I enable dircache in the sim, then it asks if I want to overwrite the directory. I think this is because when dircache is disabled, file_exists in apps/misc.c checks for the existence of a file by trying to open it for reading. Rockbox and some other OSes allow opening directories like that, but Windows doesn't.
Comment by Alexander Levin (fml2) - Wednesday, 04 February 2009, 21:00 GMT
Couldn't we provide an option "save under other (automatically generated) name"? At least in the case that a file is pasted. I.e. if the file X.mp3 exists, the pasted file would be saved as X(1).mp3. (The "(1)" part would be generated automatically. We'd have to find such n that X(n).mp3 does not exist.) Or is it too much of good?
Comment by Boris Gjenero (dreamlayers) - Thursday, 05 February 2009, 00:32 GMT
The create_numbered_filename function could be used to create the automatically generated name. Also note that there's the case where one directory is overwriting another directory, and only some files in that directory and/or its subdirectories conflict. I am wondering if this would be a useful feature or needless bloat.

I found another issue: overwriting a directory with a file or a file with a directory fails, and this happens with both cut and copy, and even with the patch I submitted.

Comment by Alexander Levin (fml2) - Thursday, 05 February 2009, 06:27 GMT
Yes, I see the issues with copying directories and conflicts in files/subdirs, therefore I proposed this for files only. But I still think it might be useful. Imagine that you copied/cut a file, then navigated a log way to another directory. Now you want to paste but the file already exists. You didn't know that and don't want to overwrite. So you first have to rename the old file. If the file to be pasted is still in the "clipboard" then there's no problem. But if it's forgotten then you have to go back to the file, copy it, go again a long way and paste.

The issue with copying files over a dir or vice versa is of course a bug. I think, there is a function "dir_exists" which should also be called prior to copying.

Loading...