mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 786662 - Open Containing Folder in context menu for Download Panel item is always disabled after pause. r=mak.
This commit is contained in:
parent
cb14ba0d8d
commit
c96071316c
@ -1114,7 +1114,8 @@ DownloadsViewItemController.prototype = {
|
||||
return this.dataItem.openable && this.dataItem.localFile.exists();
|
||||
}
|
||||
case "downloadsCmd_show": {
|
||||
return this.dataItem.localFile.exists();
|
||||
return this.dataItem.localFile.exists() ||
|
||||
this.dataItem.partFile.exists();
|
||||
}
|
||||
case "downloadsCmd_pauseResume":
|
||||
return this.dataItem.inProgress && this.dataItem.resumable;
|
||||
|
@ -80,6 +80,8 @@ XPCOMUtils.defineLazyGetter(this, "DownloadsLocalFileCtor", function () {
|
||||
"nsILocalFile", "initWithPath");
|
||||
});
|
||||
|
||||
const kPartialDownloadSuffix = ".part";
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// DownloadsCommon
|
||||
|
||||
@ -870,19 +872,48 @@ DownloadsDataItem.prototype = {
|
||||
* Windows path is stored and then the item is accessed on a Mac.
|
||||
*/
|
||||
get localFile()
|
||||
{
|
||||
return this._getFile(this.file);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the nsILocalFile for the partially downloaded target.
|
||||
*
|
||||
* @throws if the native path is not valid. This can happen if the same
|
||||
* profile is used on different platforms, for example if a native
|
||||
* Windows path is stored and then the item is accessed on a Mac.
|
||||
*/
|
||||
get partFile()
|
||||
{
|
||||
return this._getFile(this.file + kPartialDownloadSuffix);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an nsILocalFile for aFilename. aFilename might be a file URL or
|
||||
* a native path.
|
||||
*
|
||||
* @param aFilename the filename of the file to retrieve.
|
||||
* @return an nsILocalFile for the file.
|
||||
* @throws if the native path is not valid. This can happen if the same
|
||||
* profile is used on different platforms, for example if a native
|
||||
* Windows path is stored and then the item is accessed on a Mac.
|
||||
* @note This function makes no guarantees about the file's existence -
|
||||
* callers should check that the returned file exists.
|
||||
*/
|
||||
_getFile: function DDI__getFile(aFilename)
|
||||
{
|
||||
// The download database may contain targets stored as file URLs or native
|
||||
// paths. This can still be true for previously stored items, even if new
|
||||
// items are stored using their file URL. See also bug 239948 comment 12.
|
||||
if (this.file.startsWith("file:")) {
|
||||
if (aFilename.startsWith("file:")) {
|
||||
// Assume the file URL we obtained from the downloads database or from the
|
||||
// "spec" property of the target has the UTF-8 charset.
|
||||
let fileUrl = NetUtil.newURI(this.file).QueryInterface(Ci.nsIFileURL);
|
||||
let fileUrl = NetUtil.newURI(aFilename).QueryInterface(Ci.nsIFileURL);
|
||||
return fileUrl.file.clone().QueryInterface(Ci.nsILocalFile);
|
||||
} else {
|
||||
// The downloads database contains a native path. Try to create a local
|
||||
// file, though this may throw an exception if the path is invalid.
|
||||
return new DownloadsLocalFileCtor(this.file);
|
||||
return new DownloadsLocalFileCtor(aFilename);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user