Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Engines/Wine/Engine/Object/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,18 @@ Wine.prototype.kill = function () {

/**
*
* @returns {Downloader}
* @returns available Wine versions
*/
Wine.prototype.getAvailableVersions = function () {
return new Downloader()
var versionsFile = this._wineEnginesDirectory + "/availableVersions.json";
touch(versionsFile);
new Downloader()
.wizard(this._wizard)
.url(this._wineWebServiceUrl)
.get()
.to(versionsFile)
.onlyIfUpdateAvailable(true)
.get();
return cat(versionsFile);
};

/**
Expand Down
6 changes: 6 additions & 0 deletions Utils/Functions/Filesystem/Files/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ var remove = function(filePath) {
return Bean("fileUtilities").remove(new java.io.File(filePath));
};

var touch = function(filePath) {
if (!fileExists(filePath)) {
Bean("fileUtilities").writeToFile(new java.io.File(filePath), "");
}
};

var writeToFile = function(filePath, content) {
Bean("fileUtilities").writeToFile(new java.io.File(filePath), content);
};
Expand Down
19 changes: 16 additions & 3 deletions Utils/Functions/Net/Download/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ var Downloader = function () {
that._localFile = localFile;
return that;
};
that.onlyIfUpdateAvailable = function (onlyIfUpdateAvailable) {
that._onlyIfUpdateAvailable = onlyIfUpdateAvailable;
return that;
}
that.get = function () {
if (!that._message) {
that._message = tr("Please wait while {0} is downloaded ...", that._fetchFileNameFromUrl(that._url));
Expand All @@ -41,9 +45,18 @@ var Downloader = function () {
var progressBar = that._wizard.progressBar(that._message);
}

if (that._onlyIfUpdateAvailable) {
if (!that._downloader.isUpdateAvailable(that._localFile, that._url)) {
print(that._localFile + " already up-to-date.");
return;
}
}

if (that._localFile) {
that._downloader.get(that._url, that._localFile, function (progressEntity) {
progressBar.accept(progressEntity);
if (progressBar) {
progressBar.accept(progressEntity);
}
});

if (that._checksum) {
Expand All @@ -64,10 +77,10 @@ var Downloader = function () {
}
} else {
return that._downloader.get(that._url, function (progressEntity) {
if(progressBar) {
if (progressBar) {
progressBar.accept(progressEntity);
}
});
}
}
};
};