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

Bug 437216

Summary: Renaming a linked project folder incorrectly moves the files on disk
Product: [ECD] Orion Reporter: Mark Macdonald <mamacdon>
Component: ServerAssignee: Aidan Redpath <aidanr>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: ahunter.eclipse
Version: 5.0   
Target Milestone: 7.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Mark Macdonald CLA 2014-06-11 13:36:26 EDT
1. I had a clone of the orion client repo on my hard disk:
> C:\Users\mamacdon\code\orion\client 
This folder was linked [1] into Orion as a project named "orion.client" 
2. From the Orion navigator, I renamed "orion.client" to "!orion.client"
3. The server stopped responding to /file requests for a while. Eventually it gave me a generic error.

At this point, I noticed that files were vanishing from my repo folder, so I killed the server.
I ended up with part of my repo moved into a new project in the default workspace location:
> C:\Users\mamacdon\orionworkspace\foo\m\m\OrionContent\!orion.client
My old repo folder was still around

I was able to recover, but this behavior was unexpected and destructive. In previous versions of Orion (I think) you could rename a linked project without modifying the project content on disk. I expected that to still be the case.

[1] http://wiki.eclipse.org/Orion/Server_admin_guide#Configuring_paths_where_users_can_store_files

(Note: when I link a folder, I set `orion.file.allowedPaths` in the Orion conf, create the linked project, and then remove the allowedPaths entry afterward, for safety. So in step 2, the project's parent folder would not have been writable. Not sure if this matters.)
Comment 1 Mark Macdonald CLA 2014-06-11 13:42:33 EDT
There are project.json files for both projects in my workspace folder:

// orion.client.json (old project)
> {
>     "ContentLocation": "file:/C:/Users/mamacdon/code/orion/client/",
>     "FullName": "orion.client",
>     "OrionVersion": 4,
>     "Properties": {},
>     "UniqueId": "orion.client",
>     "WorkspaceId": "m-OrionContent"
> }

// !orion.client.json (renamed project)
> {
>     "ContentLocation": "file:/C:/Users/mamacdon/orionworkspace/foo/m/m/OrionContent/!orion.client",
>     "FullName": "!orion.client",
>     "OrionVersion": 4,
>     "Properties": {},
>     "UniqueId": "!orion.client",
>     "WorkspaceId": "m-OrionContent"
> }

My workspace.json contains entries for both projects:
> {
>     "FullName": "Orion Content",
>     "OrionVersion": 4,
>     "ProjectNames": [
>         "orion.client",
>           ...
>         "!orion.client"
>     ],
>     "Properties": {},
>     "UniqueId": "m-OrionContent",
>     "UserId": "m"
> }
Comment 2 Mark Macdonald CLA 2014-06-11 13:46:15 EDT
Also, I'm running the Orion server from Eclipse

> INFO  org.eclipse.orion.server.config - Server configuration file loaded from: C:\Users\mamacdon\code\orion\client\bundles\org.eclipse.orion.client.core\web-ide.conf
> INFO  org.eclipse.orion.server.config - Loaded simple metadata store (version 4).
Comment 3 Mark Macdonald CLA 2014-06-11 13:54:05 EDT
FWIW, I was able to achieve the desired behavior manually:
- Change the ProjectNames entry in workspace.json
- Change the FullName in project.json
- Rename project.json to match

^ This metadata-only operation is what I expecting to have happen originally.
Comment 4 Anthony Hunter CLA 2014-06-11 14:26:37 EDT
> I was able to recover, but this behavior was unexpected and destructive. In
> previous versions of Orion (I think) you could rename a linked project
> without modifying the project content on disk. I expected that to still be
> the case.

The linked folder name should change, but the content location should not change.
Comment 5 Aidan Redpath CLA 2014-06-17 15:14:09 EDT
The linked folder source does not have metadata file, so the server thinks it has to move it even though there is a metadata file linked to it.

https://git.eclipse.org/r/#/c/28644/1
Comment 6 Anthony Hunter CLA 2014-06-17 17:43:33 EDT
The change to WorkspaceResourceHandler is not correct. 
The line: String sourceName = source.getName(); is wrong, it is returning the name of the linked folder not the project name. 
metaStore.readProject() should not fail as this is a valid project.

The code should fall into: //a project move is simply a rename projectInfo.setFullName(destinationName); metaStore.updateProject(projectInfo);

And the metastore should handle this case.

Looks like:
String sourceName = source.getName();

Should be the final segment of sourceLocation. 

There is another bug at work here as the source location should not even exist.

For example, I update my orion.conf with:
orion.file.allowedPaths=/tmp/bee

Then create a project "Link with Server" named foo with location /tmp/bee

I can see the {user}-OrionContent/foo is being created on disk, this is wrong.

This may be a source of the problem.
Comment 7 Aidan Redpath CLA 2014-06-20 13:25:50 EDT
This problem also occurs when you try to move a linked project into another project. This is also related to https://bugs.eclipse.org/bugs/show_bug.cgi?id=437773