Skip to content
This repository has been archived by the owner on Feb 17, 2025. It is now read-only.

Commit

Permalink
update fix to include both #1394 and #1404
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylong committed Jul 27, 2018
1 parent 5de7ea4 commit bbfa40c
Showing 1 changed file with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,13 @@ private void initializeRetireJsRepo(Settings settings, URL repoUrl) throws Updat
FileOutputStream outputStream = new FileOutputStream(tmpFile)) {
IOUtils.copy(inputStream, outputStream);
}
Files.move(tmpFile.toPath(), repoFile.toPath(), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
}
} catch (IOException e) {
if (e.getMessage().contains("The system cannot move the file to a different disk drive")) {
try {
LOGGER.debug("Failed to move the file; attempting copy: " + e.getMessage());
Files.copy(tmpFile.toPath(), repoFile.toPath(), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
if (!tmpFile.delete()) {
tmpFile.deleteOnExit();
}
} catch (IOException ex) {
throw new UpdateException("Failed to initialize the RetireJS repo", ex);
//using move fails if target and destination are on different disks which does happen (see #1394 and #1404)
Files.copy(tmpFile.toPath(), repoFile.toPath(), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
if (!tmpFile.delete()) {
tmpFile.deleteOnExit();
}
}
} catch (IOException e) {
throw new UpdateException("Failed to initialize the RetireJS repo", e);
}
}
Expand Down

0 comments on commit bbfa40c

Please sign in to comment.