Bug 189041 - incorrect file name after rename a file inside a zip file - DStore Windows
Summary: incorrect file name after rename a file inside a zip file - DStore Windows
Status: CLOSED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 2.0   Edit
Assignee: David McKnight CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-05-24 17:28 EDT by Xuan Chen CLA
Modified: 2011-05-25 10:07 EDT (History)
0 users

See Also:


Attachments
Fix - need to call ArchiveHandlerManager.cleanUpVirtualPath in DStoreHostFile#renameTo() (1.68 KB, patch)
2007-05-28 00:25 EDT, Xuan Chen CLA
no flags Details | Diff
Updated fix - should not remove checking for '\\'. (1.57 KB, patch)
2007-05-28 10:53 EDT, Xuan Chen CLA
mober.at+eclipse: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Xuan Chen CLA 2007-05-24 17:28:49 EDT
The zip file I used to recreate this problem had one folder called 6YLT5X,
and inside this folder, I had four subfolders.  One of the subfolder is named 20070305a.  And inside the subfolder, there is a file called QB5ROUTE

I expanded 6YLT5X, expand subfolder 20070305a, then rename file QB5ROUTE to QB5ROUTEa.  The renamed file name shown in the System view is  20070305a\QB5ROUTEa.


-----------Enter bugs above this line-----------
TM 2.0M7 Testing
installation : eclipse-platform-3.3M7 (I20070503-1400)
RSE install  : Dev driver
java.runtime : Sun 1.5.0_06-b05
os.name:     : Windows XP 5.1, Service Pack 2
------------------------------------------------
systemtype   : Windows - DStore
------------------------------------------------
Comment 1 Xuan Chen CLA 2007-05-24 17:30:00 EDT
It seems the logic in DStoreHostFile#renameTo() could not determine the name of a file inside a zip file correctly.
Comment 2 Xuan Chen CLA 2007-05-25 00:53:03 EDT
I compared two renameTo() methods:

VirtualChild#renameTo(String newName)  
   -- called by the renaming of a virtual file by local connection

DStoreHostFile#renameTo(String newAbsolutePath) 
   -- called by the renaming of a virtual file by DStore connection.

VirtualChild#renameTo(String newName)
	{
		newName = ArchiveHandlerManager.cleanUpVirtualPath(newName);
		fullName = newName;
		int i = newName.lastIndexOf("/"); //$NON-NLS-1$
		if (i == -1)
		{
			name = newName;
			path = ""; //$NON-NLS-1$
		}
		else
		{
			name = newName.substring(i+1);
			path = newName.substring(0, i);
		}
		// force reextraction of temp file
		_extractedFile = null;
		
	}

DStoreHostFile#renameTo(String newAbsolutePath) 
	{
		String current = getName();
		
		int lastSep = newAbsolutePath.lastIndexOf('/');
		if (lastSep == -1)
			lastSep = newAbsolutePath.lastIndexOf('\\');
		
		String newName = newAbsolutePath.substring(lastSep + 1);

		if (newName.equals(current))
		{
			// data element already updated
		}
		else
		{				

			
			_element.setAttribute(DE.A_NAME, newName);
		}
		
		_isArchive = internalIsArchive();
	}

In my case, the full path of the virtual file name is:

D:\\tmp\\mynewzip.zip#virtual#/6YLT5Xa/20070315\\QB5ROUTaa

As we can see, in VirtualChild#renameTo(String newName), ArchiveHandlerManager.cleanUpVirtualPath(newName) is called first to covert all the backslash to slash, but DStoreHostFile#renameTo(String newAbsolutePath) does not.  So it gets the name as "20070315\\QB5ROUTaa", instead of "QB5ROUTaa".

We need to change the implementation of DStoreHostFile#renameTo() to be similar to VirtualChild#renameTo().
Comment 3 Martin Oberhuber CLA 2007-05-25 13:50:16 EDT
Can we apply Xuan's idea?
Comment 4 David McKnight CLA 2007-05-25 13:58:36 EDT
Yes, we should use that cleanupvirtualpath method.
Comment 5 Xuan Chen CLA 2007-05-25 23:38:47 EDT
I will test it and provide the patch.  Thanks.
Comment 6 Xuan Chen CLA 2007-05-28 00:25:25 EDT
Created attachment 68889 [details]
Fix - need to call ArchiveHandlerManager.cleanUpVirtualPath in DStoreHostFile#renameTo()

Legal Message: I, Xuan Chen, declare that I developed attached code from
scratch, without referencing any 3rd party materials except material licensed
under the EPL. I am authorized by my employer, IBM Canada Ltd. to make this
contribution under the EPL.
Comment 7 Xuan Chen CLA 2007-05-28 10:00:01 EDT
There is some problem in the previous provided patch.  I should not remove the code for finding index of '\\'.  Unlike VirtualChild#renameTo(String newName) which is only for archive files, DStoreHostFile#renameTo() applies for other files as well.

I will provide an update version of patch.

Thanks.
Comment 8 Xuan Chen CLA 2007-05-28 10:53:46 EDT
Created attachment 68927 [details]
Updated fix - should not remove checking for '\\'.

Legal Message: I, Xuan Chen, declare that I developed attached code from
scratch, without referencing any 3rd party materials except material licensed
under the EPL. I am authorized by my employer, IBM Canada Ltd. to make this
contribution under the EPL.
Comment 9 David McKnight CLA 2007-05-28 12:02:03 EDT
I've applied and committed the patch.
Comment 10 Xuan Chen CLA 2007-06-21 16:25:01 EDT
fixed in 2.0 RC4 driver.
Comment 11 Martin Oberhuber CLA 2008-08-13 13:20:18 EDT
[target cleanup] 2.0 RC2 was the original target milestone for this bug