Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

"Text file busy" (from sun.nio.fs.UnixCopyFile.move(UnixCopyFile.java:455)) #8

Open
@lauzond

Description

@lauzond

zsync-core/src/main/java/com/salesforce/zsync/internal/OutputFileWriter.java#L214
With Java OpenJDK 1.7.0_181 under a Docker container running in VirtualBox 5.2.8 and sharing a Windows folder to the Linux VM, Files.move gives the error :
"Text file busy" (from sun.nio.fs.UnixCopyFile.move(UnixCopyFile.java:455))

To fix, close the channel before the move:
Enclose lines:
zsync-core/src/main/java/com/salesforce/zsync/internal/OutputFileWriter.java#L209
to
zsync-core/src/main/java/com/salesforce/zsync/internal/OutputFileWriter.java#L213
in a try-finally block and move
zsync-core/src/main/java/com/salesforce/zsync/internal/OutputFileWriter.java#L221
to the finally part of that new try-finally

Final result:

try {
  try {
    this.channel.position(0); // reset channel to beginning to compute full SHA1
    String calculatedSha1 = ZsyncUtil.computeSha1(this.channel);
    if (!this.sha1.equals(calculatedSha1)) {
      throw new ChecksumValidationIOException(this.sha1, calculatedSha1);
    }
  } finally {
    this.channel.close(); 
  }
  
  try {
    Files.move(this.tempPath, this.path, REPLACE_EXISTING, ATOMIC_MOVE);
  } catch (AtomicMoveNotSupportedException e) {
    Files.move(this.tempPath, this.path, REPLACE_EXISTING);
  }
  Files.setLastModifiedTime(this.path, fromMillis(this.mtime));
} finally {
  this.listener.close();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions