kosivantsov / omegat_scripts

Scripts for OmegaT

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Customizer runs forever with error that destination file exists

msoutopico opened this issue · comments

Preconditions

OmegaT 4.x.x installed in a machine running Windows 10.
Script application_startup\updateConfigBundle.groovy is version 0.4.9 and def customUrl = ""
File customisation.properties has url: https://cat.capstan.be/OmegaT/dev2021_049/index.php
Local customization version 57_cs0 (2020-11-25)
Remote customization version 58_c0p (2020-11-26)

Local plugins:

  • okapiFiltersForOmegaT-1.6-m40-capstan.jar
  • omegat-bidimarkers-0.2.0-all.jar
  • plugin-omt-package-1.6.3.jar

Remote plugins:

  • okapiFiltersForOmegaT-1.8-1.40.0-capstan.jar (NEW)
  • omegat-bidimarkers-0.2.0-all.jar
  • plugin-omt-package-1.6.3.jar

Steps to reproduce

Just launch OmegaT.

Expected results

The script runs and sees that okapiFiltersForOmegaT-1.8-1.40.0-capstan.jar is a new version of okapiFiltersForOmegaT-1.6-m40-capstan.jar, so the former must replace the latter.

The new version is downloaded and, after OmegaT shuts down, the old version of the plugin is deleted (by means of the bat file triggered by the script).

Actual results

The progress bar dialog runs forever and the script fails with error javax.script.ScriptException: javax.script.ScriptException: org.apache.commons.io.FileExistsException: Destination 'C:\Users\souto\AppData\Roaming\OmegaT\plugins\omegat-bidimarkers-0.2.0-all.jar' already exists.

See full console output:

========================================
          Customisation Update
========================================
Local customisation version is 51_c0p.
Remote customisation version is 53_cs0.
Customisation update available:
* Config needs to be updated.
* Scripts need to be updated.
* Plugins need to be updated.
----------------------------------------
config.zip is being downloaded...
config.zip is being unpacked...
Customisation is being updated...
OmegaT will need to be restarted.
    -- Done --
----------------------------------------
scripts.zip is being downloaded...
scripts.zip is being unpacked...
Scripts are being installed...
Scripts provided 
in the customisation bundle 
copied to 
  C:\Users\souto\AppData\Roaming\OmegaT\scripts.
    -- Done --
----------------------------------------
plugins.zip is being downloaded...
plugins.zip is being unpacked...
Plugins are being installed...
  --
Folder
  C:\Program Files\OmegaT\plugins
is not writable, but it contains file(s)
which should be updated by this
customisation update utility:

    C:\Program Files\OmegaT\plugins\plugin-omt-package-1.6.3.jar
    C:\Program Files\OmegaT\plugins\plugin-omt-package-1.6.3.jar

Make sure the listed files are deleted
before you start OmegaT again.
The newer versions of these files
will be installed
into user's configuration folder.
  --
An error occurred
javax.script.ScriptException: javax.script.ScriptException: org.apache.commons.io.FileExistsException: Destination 'C:\Users\souto\AppData\Roaming\OmegaT\plugins\omegat-bidimarkers-0.2.0-all.jar' already exists

Reproduced in my machine. Other users haver reported same behaviour (customizer runs forever), although I couldn't see whether they had the same error.

The only way to stop that is to close the progress bar dialog, which closes OmegaT. The version_notes.txt is updated/overwritten, whereas the local_version_notes.txt remains unaltered.

Sample jar files can be downloaded from https://capps.capstan.be/Files/plugins.zip

Screencast that shows the problem: https://recordit.co/8qceTOldMj

Another one, although with a less realistic scenario: https://recordit.co/BD63bmEs34

Not sure why this issue happens, but I assume it is because the script tries to put a jar file in the plugins folder and it can't because the file (a file with the same name) is already there (with the same name) and/or because the file is locked.

If that's the case, to make things easier, I think it should be reasonable to assume that a new version of a plugin should always have a new name (a higher version number). The implication is that script doesn't try to overwrite jar files that have the same name.

In other words, for each jar file in the plugins.zip bundle, it checks whether it is in the plugins folder already):

  1. if it is, it passes and moves to the next one
  2. if it's not,
    a. it writes the jar file to the plugins folder and
    b. checks whether there's a older version of the same plugin, to delete it later (after OmegaT is killed) by means of the bat file.

In a nutshell: skip file instead of overwriting (that would be the only change).

The above is of course a compromise, because the ideal behavior is that it writes all files in the plugins.zip bundle to the plugins folder, overwrites any file that might be already there. If that's not feasible or easy to achieve, we can go with the above.