Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Tune write access verification on Windows #340

Merged
merged 1 commit into from
Oct 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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