feat(daemon): add checkLockFile helper

This commit is contained in:
George Lima 2019-05-30 15:47:55 -03:00
parent 240805c9b7
commit f2ff156d8e
1 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,19 @@
// @flow
import fs from 'fs';
import path from 'path';
import { promisify } from 'util';
import eres from 'eres';
import { getZcashFolder } from './get-zcash-folder';
const ZCASH_LOCK_FILE = '.lock';
export const checkLockFile = async (zcashPath?: string) => {
try {
const myPath = zcashPath || getZcashFolder();
const [cannotAccess] = await eres(promisify(fs.access)(path.join(myPath, ZCASH_LOCK_FILE)));
return !cannotAccess;
} catch (err) {
return false;
}
};