This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 180116 - "Folder copying not supported" from FileObject.move
Summary: "Folder copying not supported" from FileObject.move
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Filesystems (show other bugs)
Version: 6.x
Hardware: PC Linux
: P2 normal (vote)
Assignee: Jaroslav Tulach
URL:
Keywords:
Depends on:
Blocks: 162718
  Show dependency tree
 
Reported: 2010-02-01 13:47 UTC by Jesse Glick
Modified: 2010-02-12 03:22 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2010-02-01 13:47:33 UTC
When I try to call .move(...) on a FileObject representing a (disk) folder, whether the target is on the same Linux filesystem or a different one, I get:

org.openide.filesystems.FSException: Folder copying not supported.
        at org.openide.filesystems.FileObject.copy(FileObject.java:120)
        at org.openide.filesystems.FileObject.move(FileObject.java:147)
        at org.netbeans.modules.masterfs.filebasedfs.fileobjects.BaseFileObj.move(BaseFileObj.java:236)
        at org.netbeans.modules.project.uiapi.DefaultProjectOperationsImplementation.doMoveProject(DefaultProjectOperationsImplementation.java:445)

(This is with a folder which is not itself versioned, though it contains a .hg dir.) masterfs ought to try to call File.rename if possible, and if that fails (e.g. cross-device rename), do a copy & delete.
Comment 1 Jaroslav Tulach 2010-02-10 02:59:16 UTC
core-main#9e464ec455df
Comment 2 Jesse Glick 2010-02-10 12:11:43 UTC
(In reply to comment #1)
> core-main#9e464ec455df

The new impl does not work at all, as you can see by making the test slightly more interesting:

diff --git a/openide.filesystems/test/unit/src/org/openide/filesystems/FileObjectTestHid.java b/openide.filesystems/test/unit/src/org/openide/filesystems/FileObjectTestHid.java
--- a/openide.filesystems/test/unit/src/org/openide/filesystems/FileObjectTestHid.java
+++ b/openide.filesystems/test/unit/src/org/openide/filesystems/FileObjectTestHid.java
@@ -446,6 +446,7 @@
         FileObject fold2 = fold.createFolder("B");
 
         FileObject toMove = fold1.createFolder("something");
+        toMove.createData("kid");
         FileLock lock = toMove.lock();
         try {
             FileObject toMove2 = null;

(target.createData should be target.createFolder.)

(In reply to comment #0)
> masterfs ought to try to call File.rename if possible

Nor was this implemented, making the impl not only inefficient (linear rather than constant time), but useless for the motivating use case of moving a project to a different folder - since a FileObject-based copy will ruin VCS metadata.

> do a copy & delete.

This was sort of implemented, but again using FileObject. masterfs needs to override this to do a File-based copy which would preserve the same byte content (unless a controlling VCS declares that it is able to do the move on its own).
Comment 3 Quality Engineering 2010-02-10 21:22:14 UTC
Integrated into 'main-golden', will be available in build *201002110200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/9e464ec455df
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #180116: Supporting move of a folder
Comment 4 Jaroslav Tulach 2010-02-11 09:26:25 UTC
Good catch. Fixed in
http://hg.netbeans.org/core-main/rev/ef4c23fd35a9

"motivating use case" - do you call the exception in #0 a motivating use case? I just fixed the exception and I felt fine.

If you feel versioning is not behaving properly, then it is unlikely a fault of masterfs. I had to fix 
http://hg.netbeans.org/core-main/diff/9e464ec455df/masterfs/test/unit/src/org/netbeans/modules/masterfs/providers/ProvidedExtensionsTest.java
to deal with folders, so I expect that, as soon as versining provides its extensions, they will be in charge of doing the folder move.

If not, you need to report a bug from versioning. CCing Ondřej.
Comment 5 Jesse Glick 2010-02-11 09:58:55 UTC
(In reply to comment #4)
> "motivating use case" - do you call the exception in #0 a motivating use case?

No.

> If you feel versioning is not behaving properly, then it is unlikely a fault of
> masterfs.

No, it is a problem in masterfs. If the folder is a versioned _subfolder_ then it is fine for a VCS provider to handle the move. But the case in question is when the folder being moved is a VCS _root_.

See bug #162718 for example. Try to apply the patch given there, then

1. Create a j2seproject in /tmp1.

2. Init Hg repo in it, do initial commit.

3. Try to move it to /tmp2.

You get /tmp2/JavaApplication5/JavaApplication5 with a file (not dir) .hg containing

---%<---
revlogv1
store
fncache
---%<---

which was one of its contents. And you get an exception:

java.io.SyncFailedException: /space/tmp/JavaApplication5/JavaApplication5/.hg
        at org.netbeans.modules.masterfs.filebasedfs.fileobjects.FolderObj.createFolder(FolderObj.java:197)
        at org.netbeans.modules.masterfs.filebasedfs.fileobjects.FolderObj.createFolderImpl(FolderObj.java:161)
        at org.netbeans.modules.masterfs.filebasedfs.fileobjects.FolderObj$2.call(FolderObj.java:219)
        at org.netbeans.modules.masterfs.filebasedfs.fileobjects.FolderObj$2.call(FolderObj.java:217)
        at org.netbeans.modules.masterfs.filebasedfs.FileBasedFileSystem.runAsInconsistent(FileBasedFileSystem.java:112)
        at org.netbeans.modules.masterfs.filebasedfs.fileobjects.FolderObj.createFolder(FolderObj.java:222)
        at org.openide.filesystems.FileObject.copy(FileObject.java:120)
        at org.openide.filesystems.FileObject.copy(FileObject.java:123)
        at org.openide.filesystems.FileObject.copy(FileObject.java:123)
        at org.openide.filesystems.FileObject.move(FileObject.java:152)
        at org.netbeans.modules.masterfs.filebasedfs.fileobjects.BaseFileObj.move(BaseFileObj.java:236)
        at org.netbeans.modules.project.uiapi.DefaultProjectOperationsImplementation.doMoveProject(DefaultProjectOperationsImplementation.java:448)
Comment 6 Quality Engineering 2010-02-11 21:18:34 UTC
Integrated into 'main-golden', will be available in build *201002120200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/ef4c23fd35a9
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: Correction of #180116: When copying a folder, create a folder.
Comment 7 Jaroslav Tulach 2010-02-12 03:22:37 UTC
Stop reopening my bug! OK, I fixed it for yet another time: core-main#5be5523c8c96 I also tried to run with patch for bug 162718. The .hg directory has been preserved when I moved the project elsewhere (the IDE mercurial support did not notice that, but that is another bug, I hope).