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 244286 - Moving a project does not preserve file and folder timestamps
Summary: Moving a project does not preserve file and folder timestamps
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Filesystems (show other bugs)
Version: 8.0
Hardware: PC Windows 7
: P1 normal (vote)
Assignee: Jaroslav Havlin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-04 22:20 UTC by michaelmilette
Modified: 2014-07-19 10:16 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Partial Fix (1.30 KB, patch)
2014-05-16 10:31 UTC, Jaroslav Havlin
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description michaelmilette 2014-05-04 22:20:39 UTC
ISSUE

This issue results in the loss of data in the form of operating system file and folder modified date/time stamp records. 

WHAT HAPPEN

The timestamp of all source files and folders change to the current date and time when moving a project from within NetBeans.

WHAT I EXPECTED

When moving a project to a different location on the local PC, I expected the modified date and time stamp of all files, possibly also folders (directories) to be preserved.

While I can't think if any reason this should not be possible, if it isn't, there should be some kind of warning telling the user the modified date of all of their files and folders is going to be reset to the current date.

WHY THIS IS IMPORTANT

I rely heavily on date/timestamps and this side effect of the move was unexpected and took me several hours and I only manager to get most of it back the to the way it was before the move.

STEPS TO REPRODUCE

Note that this process can be extremely slow for larger projects. Please be patient.

1) Create a new project with the NetBeans project file in the same folder as existing source code.

2) Right-click on the project you want to move in the "projects" tab and then click "move". 

3) Enter a new location and click Move. 

4) Once the process is done, notice that the date and time stamp of all of the files will have changed.
Comment 1 Jaroslav Havlin 2014-05-16 10:31:53 UTC
Created attachment 147296 [details]
Partial Fix
Comment 2 Jaroslav Havlin 2014-05-16 11:07:45 UTC
The attached patch works only if the project uses no version control system.

If some versioning is used by the project, moving is handled by a VCSInterceptor, which would need to be updated as well to set the last-modified time correctly.

I've noticed that FileSystemInterceptor in git module contains this method:

  copyDirFiles(File sourceDir, File targetDir, boolean preserveTimestamp)

This method is called from method doCopy with parameter preserveTimestamp = false.
I guess there can be a good reason for this (probably performance).

Ondra, is calling this method with preserveTimestamp = true risky?
Can versioning modules be safely updated to preserve timestamps when copying files?
Thank you.



> I rely heavily on date/timestamps and this side effect of the move was unexpected and
> took me several hours and I only manager to get most of it back the to the way it was
> before the move.
It seems quite risky to me. Various tools (other than NetBeans) can update last-modified time unexpectedly. I would recommend using some VCS whenever it is applicable. It can track history of changes and offers many other benefits.

Not sure this is P1, as only meta-data were lost. And last-modified time can be considered as quite a fragile piece of meta-data.

Thank you for reporting.
Comment 3 Ondrej Vrabec 2014-05-16 15:54:55 UTC
> The attached patch works only if the project uses no version control system.
> If some versioning is used by the project, moving is handled by a VCSInterceptor, which would need to be updated as well to set the last-modified time correctly.
> I've noticed that FileSystemInterceptor in git module contains this method:
>   copyDirFiles(File sourceDir, File targetDir, boolean preserveTimestamp)
> This method is called from method doCopy with parameter preserveTimestamp = false.
> I guess there can be a good reason for this (probably performance).
> Ondra, is calling this method with preserveTimestamp = true risky?
> Can versioning modules be safely updated to preserve timestamps when copying files?
It makes sense to keep timestamp for moves/renames, but for copies? Are you sure it's the right way? I am not so convinced. Much more straightforward would be to call move instead of copy+delete. But i guess all versioning modules could be forced to keep the timestamp for copies if necessary.
> Not sure this is P1, as only meta-data were lost. And last-modified time can be considered as quite a fragile piece of meta-data.
sounds like a P4 to me, especially in case of renaming a project via UI. If the reporter is interested in keeping all timestamp i suggest renaminhg/moving in the favorites view.
Comment 4 Jaroslav Havlin 2014-07-16 13:59:15 UTC
http://hg.netbeans.org/core-main/rev/eb47861d08e2
Fixed.
Thank you.
Comment 5 Ondrej Vrabec 2014-07-17 13:43:10 UTC
fix: http://hg.netbeans.org/core-main/rev/725e98325c77
Comment 6 Quality Engineering 2014-07-19 10:16:11 UTC
Integrated into 'main-silver', will be available in build *201407190718* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/eb47861d08e2
User: Jaroslav Havlin <jhavlin@netbeans.org>
Log: #244286: Moving a project does not preserve file and folder timestamps

The copy operation is used internally during move. To recognize that the copy
is called from a move (without API changes), new thread local variable was
introduced. If this variable is set to true, the last-modified date of the target
file is set after copying.

Using NIO2, which could make the implementation simpler, should be considered
for the next release.