Skip to content

Commit

Permalink
fix: Tune write access verification on Windows (#340)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach authored Oct 5, 2019
1 parent 7e2fdd5 commit 30497d4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/helpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from 'path';
import { fs } from 'appium-support';
import { fs, system } from 'appium-support';


let helpers = {};

Expand All @@ -18,8 +19,15 @@ helpers.ensureInternetPermissionForApp = async function (adb, app) {
helpers.isWriteable = async function isWriteable (filePath) {
try {
await fs.access(filePath, fs.W_OK);
if (system.isWindows()) {
// On operating systems, where access-control policies may
// limit access to the file system, `fs.access` does not work
// as expected. See https://groups.google.com/forum/#!topic/nodejs/qmZtIwDRSYo
// for more details
await fs.close(await fs.open(filePath, 'r+'));
}
return true;
} catch (e) {
} catch (ign) {
return false;
}
};
Expand Down

0 comments on commit 30497d4

Please sign in to comment.