Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 409181

Summary: Import local file... silently overwrites destination
Product: [ECD] Orion Reporter: Mike Wilson <Mike_Wilson>
Component: ClientAssignee: Project Inbox <orion.client-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ahunter.eclipse, libingw
Version: unspecifiedFlags: ahunter.eclipse: review? (john.arthorne)
Target Milestone: 7.0   
Hardware: PC   
OS: Mac OS X   
Whiteboard:

Description Mike Wilson CLA 2013-05-27 13:05:15 EDT
If there is already a file in the destination folder with the same name as the file being imported, we currently silently overwrite the file.

We should either prompt before overwriting, or automatically rename the file.
Comment 1 Anthony Hunter CLA 2013-06-04 11:03:44 EDT
When you import a zip file and select to unzip, the ClientImport support on the server checks for existing files and prompts to overwrite.

I have updated ClientImport.completeMove() to use this same logic done by ClientImport.completeUnzip().

As a result, when the file exists, the user is prompted:

Failed to transfer the file to [FILE], the existing file could not be overwritten
Would you like to retry the import with force overwriting?

If the user selects ok, the file will be overwritten.

As a result of the server change, there is no changes needed to the client code since we use the existing support that the zip files take advantage of.

The changes are at:
https://github.com/ahunter-orion/orion.server/commit/b5365063b77e13f32491fb08c7bb3cbcc2c075ff

I assert that I authored 100% of the content of this contribution and have the rights to donate the content to Eclipse under the EPL
Comment 2 John Arthorne CLA 2013-06-11 15:04:40 EDT
In our other API we use a header like this to indicate that the request should not overwrite:

X-Xfer-Options: no-overwrite

See ProtocolConstants.OPTION_NO_OVERWRITE and the various references. So the expectation is that overwrite will occur unless told otherwise. Zip import should be consistent with this.

A header is easier for the client to use because they don't have to do any direct URL manipulation and avoids colliding with any existing query on the resource.

Also can you add a regression test for this. See TransferTest.java.
Comment 3 Anthony Hunter CLA 2013-06-12 15:03:54 EDT
(In reply to comment #2)
> In our other API we use a header like this to indicate that the request
> should not overwrite:
> 
> X-Xfer-Options: no-overwrite
> 
> See ProtocolConstants.OPTION_NO_OVERWRITE and the various references. So the
> expectation is that overwrite will occur unless told otherwise. Zip import
> should be consistent with this.
> 
> A header is easier for the client to use because they don't have to do any
> direct URL manipulation and avoids colliding with any existing query on the
> resource.
> 
> Also can you add a regression test for this. See TransferTest.java.

ok, both import local file and import local zip file must have been written before the File API was finalized and both need to be updated to use those API headers.
Comment 4 Aidan Redpath CLA 2014-09-25 09:10:52 EDT
(In reply to Anthony Hunter from comment #3)
> (In reply to comment #2)
> > In our other API we use a header like this to indicate that the request
> > should not overwrite:
> > 
> > X-Xfer-Options: no-overwrite
> > 
> > See ProtocolConstants.OPTION_NO_OVERWRITE and the various references. So the
> > expectation is that overwrite will occur unless told otherwise. Zip import
> > should be consistent with this.
> > 
> > A header is easier for the client to use because they don't have to do any
> > direct URL manipulation and avoids colliding with any existing query on the
> > resource.
> > 
> > Also can you add a regression test for this. See TransferTest.java.
> 
> ok, both import local file and import local zip file must have been written
> before the File API was finalized and both need to be updated to use those
> API headers.

Client change: https://git.eclipse.org/r/#/c/33841/
Sever change: https://git.eclipse.org/r/#/c/33840/
Comment 5 John Arthorne CLA 2015-05-05 16:33:35 EDT
Bug was assigned to an inactive contributor. Moving back to inbox.
Comment 6 libing wang CLA 2015-05-08 09:44:51 EDT
I verified with today's orion.eclipse.org. The bug has already been fixed per comment 1.