Check to ensure that file downloaded and is present locally before setting times (Issue #496)

* Check to see if the file was actually downloaded before attempting to set the times on the file.
* If file is not local, download failed
This commit is contained in:
abraunegg 2019-05-13 08:22:15 -04:00 committed by GitHub
parent 3e35e20cc5
commit f779881ff9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1094,11 +1094,20 @@ final class SyncEngine
downloadFailed = true;
return;
}
setTimes(path, item.mtime, item.mtime);
// file has to have downloaded in order to set the times / data for the file
if (exists(path)) {
setTimes(path, item.mtime, item.mtime);
} else {
log.error("ERROR: File failed to download. Increase logging verbosity to determine why.");
downloadFailed = true;
return;
}
}
writeln("done.");
log.fileOnly("Downloading file ", path, " ... done.");
if (!downloadFailed) {
writeln("done.");
log.fileOnly("Downloading file ", path, " ... done.");
}
}
// returns true if the given item corresponds to the local one