Skip to content

Commit

Permalink
Merge branch 'master' into gh-2884
Browse files Browse the repository at this point in the history
  • Loading branch information
retorquere committed May 20, 2024
2 parents 8bda84a + f07bcbf commit ecb40c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
13 changes: 9 additions & 4 deletions content/translators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ const $OS = is7 ? Shim : OS
import merge from 'lodash.merge'

async function guard(run: Promise<void>): Promise<boolean> {
const timeout = async () => {
let timeout = true

const delay = async () => {
await Zotero.Promise.delay(20000)
log.debug('installing translators: raced to timeout!')
throw { timeout: true, message: 'timeout' } // eslint-disable-line no-throw-literal
if (timeout) {
log.debug('installing translators: raced to timeout!')
throw { timeout: true, message: 'timeout' } // eslint-disable-line no-throw-literal
}
}

try {
await Promise.race([run, timeout()])
await Promise.race([run, delay()])
timeout = false
log.debug('installing translators: guard OK')
return true
}
Expand Down
17 changes: 2 additions & 15 deletions setup/shims/path.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
export function join(path, ...args) {
if (!args.length) return path

if (typeof OS !== 'undefined') return OS.Path.join(...arguments)

const platformSlash = Services.appinfo.OS == 'WINNT' ? '\\' : '/'
try {
if (args.length == 1 && args[0].includes(platformSlash)) return PathUtils.joinRelative(path, ...args)
return PathUtils.join(path, ...args);
}
catch (e) {
if (e.message.includes('NS_ERROR_FILE_UNRECOGNIZED_PATH')) {
Cu.reportError("WARNING: " + e.message + " -- update for IOUtils")
return [path, ...args].join(platformSlash);
}
throw e
}
var platformSlash = Services.appinfo.OS == 'WINNT' ? '\\' : '/';
return [path, ...args].join(platformSlash);
}

export function dirname(filename) {
Expand Down

0 comments on commit ecb40c2

Please sign in to comment.