Archive Folder In Use

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.

image

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.

Strange for such a small archive to be held open for that amount of time, if it isn't a virus scanner doing it.

Maybe a Process Monitor log of what happens will reveal the cause:

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).

Can you provide a minimal example script that demonstrates the problem?

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;
 }
}

Shouldn’t you call it file.Close(); ?

I'm used to that in JavaScript too, but in Opus that throws errors, whereas .Close without parenthesis doesn't.

Object doesn't support this property or method (0x800a01b6)

I believe you define your file var wrong. It’s not data.item, it should be data.item.Open() per docs.

Then you could read the content via file.Read() and close the file correctly via file.Close();

I don't think so, else .size doesn't exist or work.

Replacing every single file with data.item will yield the same result:

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 res = 0;
  if (data.item.size == 0) {
   res = -1;
  } else if (!data.item.Open.error) {
   var txt = data.item.Open.Read(2);
   data.item.Close;
   res = (DOpus.Create.StringTools.Decode(txt,'utf-8') == 'en') ? 1 : -1;
  }
  data.value = res;
 }
}

Everything works, except for .Close.

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.

I'm afraid I'm still misunderstanding it then. :disappointed: Can you please post the fixed code snippet?

Try this, but I couldn’t check it out right now:

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 res = 0;
  if (data.item.size == 0) {
   res = -1;
  } else { var openedFile = data.item.Open(); if (!openedFile.error) {
   var txt = openedFile.Read(2);
   res = (DOpus.Create.StringTools.Decode(txt,'utf-8') == 'en') ? 1 : -1;
  } openedFile.Close(); }
  data.value = res;
 }
}

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. :tired_face:

Thank you so much! :partying_face: