Quote:
Originally Posted by SMS
If file to be downloaded is called foo.zip, but the download directory already contains a subdirectory called foo, then foo.zip shouldn't be downloaded (for example by using link.setEnabled(false);).
|
Code:
// Disable all download link(s) of an archive, if the download folder contains a sub-folder with archive name
// Trigger: A Download Started
var archive = link.getArchive();
var archiveLinks = archive && getPath(link.getPackage().getDownloadFolder() + "/" + archive.getName()).exists() ? archive.getDownloadLinks() : [];
archiveLinks.forEach(function(link) {
link.setEnabled(false);
// var partFile = getPath(link.getDownloadPath() + ".part");
// if (partFile.exists()) partFile.delete();
})