Community
Participate
Working Groups
Build Identifier: M20060921-0945 Trying to move a project using the eclipse IDE, from its original location to a subdirectory of that location, will delete it instead! Reproducible: Always Steps to Reproduce: 1. Select a project from the workspace 2. Right click on it and select Refactor->Move (Shift+Alt+V) 3. If the project directory is "/home/workspace/project", the location should be set to a subdirectory such as "/home/workspace/project/code" 4. Press OK and your entire project will be deleted!
If I counted right, you are on 3.2.1, which is pretty ancient. Can you try this on 3.5.2? Also, you did not specify if you are using the Project Explorer or Package Explorer (they go to different departments around here).
I tried this on Windows 7 with an e4 I20100319-2100 build. Package Explorer: My 'src/' folder and .classpath file was destroyed. Project Explorer: Same as above. Navigator: Same as above.
Attempting to undo did not work. It seems the move operation alone caused exceptions to be written to the log. !ENTRY org.eclipse.core.resources 4 1 2010-03-25 21:02:56.406 !MESSAGE Internal Error !STACK 1 org.eclipse.core.runtime.CoreException: File not found: D:\eclipse-e4-SDK-incubation-I20100319-2100-win32\ws\test\code\.project. at org.eclipse.core.internal.filesystem.Policy.error(Policy.java:55) at org.eclipse.core.internal.filesystem.local.LocalFile.openInputStream(LocalFile.java:371) at org.eclipse.core.internal.localstore.FileSystemResourceManager.read(FileSystemResourceManager.java:702) at org.eclipse.core.internal.resources.File.getContents(File.java:293) at org.eclipse.core.internal.localstore.FileSystemResourceManager.descriptionChanged(FileSystemResourceManager.java:287) at org.eclipse.core.internal.localstore.FileSystemResourceManager.internalWrite(FileSystemResourceManager.java:548) at org.eclipse.core.internal.resources.Project.writeDescription(Project.java:1253) at org.eclipse.core.internal.resources.Project.writeDescription(Project.java:1234) at org.eclipse.core.internal.resources.ResourceTree.movedProjectSubtree(ResourceTree.java:702) at org.eclipse.core.internal.resources.ResourceTree.standardMoveProject(ResourceTree.java:1085) at org.eclipse.core.internal.resources.Project.move(Project.java:882) at org.eclipse.ui.ide.undo.MoveProjectOperation.moveProject(MoveProjectOperation.java:167) at org.eclipse.ui.ide.undo.MoveProjectOperation.doExecute(MoveProjectOperation.java:135) at org.eclipse.ui.ide.undo.AbstractWorkspaceOperation$1.run(AbstractWorkspaceOperation.java:206) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975) at org.eclipse.ui.ide.undo.AbstractWorkspaceOperation.execute(AbstractWorkspaceOperation.java:204) at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:511) at org.eclipse.ui.actions.MoveProjectAction$1.run(MoveProjectAction.java:112) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121) Caused by: java.io.FileNotFoundException: D:\eclipse-e4-SDK-incubation-I20100319-2100-win32\ws\test\code\.project (The system cannot find the path specified) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(Unknown Source) at org.eclipse.core.internal.filesystem.local.LocalFile.openInputStream(LocalFile.java:362) ... 17 more !SUBENTRY 1 org.eclipse.core.filesystem 4 271 2010-03-25 21:02:56.407 !MESSAGE File not found: D:\eclipse-e4-SDK-incubation-I20100319-2100-win32\ws\test\code\.project. !STACK 0 java.io.FileNotFoundException: D:\eclipse-e4-SDK-incubation-I20100319-2100-win32\ws\test\code\.project (The system cannot find the path specified) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(Unknown Source) at org.eclipse.core.internal.filesystem.local.LocalFile.openInputStream(LocalFile.java:362) at org.eclipse.core.internal.localstore.FileSystemResourceManager.read(FileSystemResourceManager.java:702) at org.eclipse.core.internal.resources.File.getContents(File.java:293) at org.eclipse.core.internal.localstore.FileSystemResourceManager.descriptionChanged(FileSystemResourceManager.java:287) at org.eclipse.core.internal.localstore.FileSystemResourceManager.internalWrite(FileSystemResourceManager.java:548) at org.eclipse.core.internal.resources.Project.writeDescription(Project.java:1253) at org.eclipse.core.internal.resources.Project.writeDescription(Project.java:1234) at org.eclipse.core.internal.resources.ResourceTree.movedProjectSubtree(ResourceTree.java:702) at org.eclipse.core.internal.resources.ResourceTree.standardMoveProject(ResourceTree.java:1085) at org.eclipse.core.internal.resources.Project.move(Project.java:882) at org.eclipse.ui.ide.undo.MoveProjectOperation.moveProject(MoveProjectOperation.java:167) at org.eclipse.ui.ide.undo.MoveProjectOperation.doExecute(MoveProjectOperation.java:135) at org.eclipse.ui.ide.undo.AbstractWorkspaceOperation$1.run(AbstractWorkspaceOperation.java:206) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975) at org.eclipse.ui.ide.undo.AbstractWorkspaceOperation.execute(AbstractWorkspaceOperation.java:204) at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:511) at org.eclipse.ui.actions.MoveProjectAction$1.run(MoveProjectAction.java:112) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121) !ENTRY org.eclipse.ui 4 4 2010-03-25 21:03:18.366 !MESSAGE Problems encountered while moving resources. !ENTRY org.eclipse.ui 4 0 2010-03-25 21:03:18.367 !MESSAGE Problems encountered while moving resources. !STACK 1 org.eclipse.core.internal.resources.ResourceException: Problems encountered while moving resources. at org.eclipse.core.internal.resources.Project.move(Project.java:889) at org.eclipse.ui.ide.undo.MoveProjectOperation.moveProject(MoveProjectOperation.java:167) at org.eclipse.ui.ide.undo.MoveProjectOperation.doExecute(MoveProjectOperation.java:135) at org.eclipse.ui.ide.undo.MoveProjectOperation.doUndo(MoveProjectOperation.java:150) at org.eclipse.ui.ide.undo.AbstractWorkspaceOperation$3.run(AbstractWorkspaceOperation.java:287) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975) at org.eclipse.ui.ide.undo.AbstractWorkspaceOperation.undo(AbstractWorkspaceOperation.java:285) at org.eclipse.core.commands.operations.DefaultOperationHistory.doUndo(DefaultOperationHistory.java:415) at org.eclipse.core.commands.operations.DefaultOperationHistory.undo(DefaultOperationHistory.java:1280) at org.eclipse.ui.operations.UndoActionHandler.runCommand(UndoActionHandler.java:78) at org.eclipse.ui.operations.OperationHistoryActionHandler$4.run(OperationHistoryActionHandler.java:311) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121) Contains: Resource already exists on disk: 'D:\eclipse-e4-SDK-incubation-I20100319-2100-win32\ws\test'. !SUBENTRY 1 org.eclipse.core.resources 1 4 2010-03-25 21:03:18.368 !MESSAGE Problems encountered while moving resources. !SUBENTRY 2 org.eclipse.core.resources 1 4 2010-03-25 21:03:18.368 !MESSAGE Resource already exists on disk: 'D:\eclipse-e4-SDK-incubation-I20100319-2100-win32\ws\test'.
Resources, please take a look.
Created attachment 180402 [details] Changes "move" opperation on FileStore
Created attachment 180403 [details] Validation fix
I've investigated this bug and it's caused by our implementation of "move" opperation on file store. The move function first copies the given resouce to its destination than deletes the oryginal resource. If we are trying to move a folder into its own subfolder than first it's copied than it's deleting while deleting it's first location. I've attached a fix for this using the temporary folder while moving, however I relize that this is a big change in file handling and you may hasitate to commit it. I think that the first intention was to prevent user from moving the project into it's own directory. I noticed that validation prevents this change but only when project is situated in non-default folder. I tried to move back in the file history to find out why default locations are not validated but it seems that it has been introduced in the initial version of the validator. The second fix I submitted changes the validator so that it verifies all projects, including those located in default locations.
(In reply to comment #7) > I think that the first intention was to prevent user from moving the project > into it's own directory. I noticed that validation prevents this change but only > when project is situated in non-default folder. Right, the second proposal looks better. Just add some tests, please.
Created attachment 180490 [details] Fixed validation and added jUnit
Created attachment 180497 [details] Fixed validation and added jUnit (refactored)
I made some changes in the tests. Otherwise looks good. Thanks.
*** Bug 339814 has been marked as a duplicate of this bug. ***
Hi, sorry for being so late with the follow-up, but this till fails with 3.7.0 I can no longer reproduce from the GUI, because it prevents it, but at the API level the standardMove operation deletes everything. // Before // /Users/me/SW/junit-workspace//P // /Users/me/SW/junit-workspace//P/Project-1 // /Users/me/SW/junit-workspace//P/Project-1/.classpath // /Users/me/SW/junit-workspace//P/Project-1/.git // /Users/me/SW/junit-workspace//P/Project-1/.git/branches // /Users/me/SW/junit-workspace//P/Project-1/.git/config // /Users/me/SW/junit-workspace//P/Project-1/.git/HEAD // /Users/me/SW/junit-workspace//P/Project-1/.git/hooks // /Users/me/SW/junit-workspace//P/Project-1/.git/index // /Users/me/SW/junit-workspace//P/Project-1/.git/logs // /Users/me/SW/junit-workspace//P/Project-1/.git/logs/refs // /Users/me/SW/junit-workspace//P/Project-1/.git/logs/refs/heads // /Users/me/SW/junit-workspace//P/Project-1/.git/objects // /Users/me/SW/junit-workspace//P/Project-1/.git/objects/b6 // /Users/me/SW/junit-workspace//P/Project-1/.git/objects/b6/49a9bf89116c581f8329b8ec3c79a86a70be04 // /Users/me/SW/junit-workspace//P/Project-1/.git/objects/info // /Users/me/SW/junit-workspace//P/Project-1/.git/objects/pack // /Users/me/SW/junit-workspace//P/Project-1/.git/refs // /Users/me/SW/junit-workspace//P/Project-1/.git/refs/heads // /Users/me/SW/junit-workspace//P/Project-1/.git/refs/tags // /Users/me/SW/junit-workspace//P/Project-1/.project // /Users/me/SW/junit-workspace//P/Project-1/bin // /Users/me/SW/junit-workspace//P/Project-1/file.txt After: // With 3.7 and earlier // /Users/me/SW/junit-workspace//P // /Users/me/SW/junit-workspace//P/Project-1 // /Users/me/SW/junit-workspace//P/Project-1/P2 // /Users/me/SW/junit-workspace//P/Project-1/P2/.project // /Users/me/SW/junit-workspace//P/Project-1/P2/bin // /Users/me/SW/junit-workspace//P/Project-1/P2/bin/.project One thing about the test in the attachment: I don't see where it tests that it actually does what is tries to do. Not crashing is not the same as passing a test.
The target milestone is confusing ... since the UI issue is fixed and only the API affected I'd suggest closing this and cloning a new bug for the API issue?
Gosia, please comment.
As i interpret the issue, it's not a UI issue. The user actually wants to do this, at least that is what I wanted to do in Bug 339814.
Created attachment 202991 [details] Enhanced test Robin, I'm attaching patch that enhances the test with some checks ensuring if contents of project was not deleted. The previous test only checked if an attempt to move the project to its subfolder returns an error, because before that it didn't. Attached test passes in my workspace, so I suppose the test doesn't exactly reflect your scenario. Could you attach a test that fails or a code snippet that would help me to create a failing test? And also could you attach the exact build id?
See http://egit.eclipse.org/r/#change,2727 patch 12 http://egit.eclipse.org/r/#patch,sidebyside,2727,12,org.eclipse.egit.core.test/src/org/eclipse/egit/core/GitMoveDeleteHookTest.java The test method is testMoveProjectWithinGitRepoMoveFromLevelZeroDownOne Build id is Build id: I20110613-1736
http://egit.eclipse.org/r/#change,2727 patch 14 does not evade the bug, but fails the tests instead.
Created attachment 203583 [details] Enhanced test that fails Thank you for the code, Robin. The difference between the two tests is that in your test the project name has been change as well. I modified my test to change the name as well and now it fails, so I know where to search for the bug.
Created attachment 203604 [details] fix with test This patch contains proposition of solution. The problem was that location is validated by Workspace.validateProjectLocationURI(project, location), but the "project" argument was not the current project, but the destination project. Those were the same projects only if the project name wasn't meant to be changed. The destination project may not exist yet or even more it might have been a completely different project if a project of given name existed in the workspace. The location validator assumed that for projects that are supposed to be moved/copied variable "project" contains the source project and not only used its current location for validation but also if project existed it validated some of its contents. So passing destination instead of a source project broke the validation. Maybe it's not a bad idea to change the javadoc for Workspace#validateProjectLocationURI(project, location) as well.
(In reply to comment #21) > Created attachment 203604 [details] > fix with test > I grabbed R3_7 of core resources, applied this patch, disabled the UI check, created a project and tried to move it down one level. The content of the project was deleted. The code still fails to rename the project to the subtree and goes down the copy/delete path.
Created attachment 203895 [details] Message displayed
(In reply to comment #22) > (In reply to comment #21) > > Created attachment 203604 [details] > > fix with test > > > > I grabbed R3_7 of core resources, applied this patch, disabled the UI check, > created a project and tried to move it down one level. The content of the > project was deleted. > > The code still fails to rename the project to the subtree and goes down the > copy/delete path. Robin, I did just the same: replaced my resources with R3_7, applied the patch, removed validation from org.eclipse.ui.internal.ide.dialogs.ProjectContentsLocationArea#checkValidLocation, then I run Eclipse and create a project in "Test1" in default location. Then I went to Refactor->Move and I've chosen location "[workspaceLocation]\Test1\Test1" which was a subdirectory of project Test1. Then I get an error message attached in attachment 203895 [details]. My project is not moved, but nothing get deleted. I tried also with existing and non existing subfolders and with non-default project locations also outside the workspace directory. I always get the same error message and nothing gets deleted. Maybe you could create a test that fails or attach a workspace with a project that can't be moved into its subfolder?
Gosia, please open a separate bug for the Robin's case and attach your patch there. Set the new bug for 3.8M4 and close Bug 307140.
(In reply to comment #25) > Gosia, please open a separate bug for the Robin's case and attach your patch > there. Set the new bug for 3.8M4 and close Bug 307140. Done, the new bug is Bug 363048.