I love Opus' Archive integration, but for some reason it automatically opens newly created or moved archives in the background (so not visibly) all by itself, making those impossible to move or delete for a few seconds.
Upon pressing 'Try Again', it works properly. Also when disabling the internal Opus Zip support, it's no issue at all, but that defeats the purpose.
The file has not been opened manually and there is no other process for it still ongoing, with it fully finished being created or moved prior. Also disabled any virus scanner and firewall to ensure it wasn't those checking it out and locking it up.
I think I found the culprit, the being kept open by a column/label script (disabling the internal Opus Zip support for no apparent reason making a difference).
It seems that File.Close doesn't do anything in JScript (whereas something like var obj = new ActiveXObject('Scripting.FileSystemObject'); obj.Close() does work and releases the file right away, but it would be nice to be able to rely on internal functions.
The documentation is unclear on this. It can be interpreted as that File.Close can be used to manually close the file, or that the file needs to be closed manually separate from .Close (in which case that's not possible, because the file isn't visibly opened).
function OnInit(initData) {
initData.default_enable = true;
var col = initData.AddColumn();
col.autogroup = false;
col.autorefresh = true;
col.label = col.name = 'English';
col.method = 'OnEnglish';
}
function OnEnglish(data) {
if (!data.item.is_dir) {
var file = data.item,
res = 0;
if (file.size == 0) {
res = -1;
} else if (!file.Open.error) {
var txt = file.Open.Read(2);
file.Close; // also tried txt.Close; just in case
res = (DOpus.Create.StringTools.Decode(txt,'utf-8') == 'en') ? 1 : -1;
}
data.value = res;
}
}
You misunderstood me. var file should point to the file opened via data.item.Open();. it has File type. but size in your script is a property of the Item type itself, so you should get it from data.item, like data.item.size.
I’m not sure how that should work: data.item.Open.error data.item.Open.Read(2);
since you don’t even call Open() here properly (or does JScript allow calls without parenthesis?). anyways, even if it does work, you open a new file each time, instead of saving the result File object once and operating on it, like I said.
For goodness sake, so it's really just like normal JavaScript. I thought I was following the docs to a tee with vanilla throwing all kinds of errors, making me think .Open was just using data.item itself and could be stored.