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

Potential workaround for issue/1684 #1685

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
24 changes: 20 additions & 4 deletions src/common/services/StorageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,26 @@ class Storage {

try {
fs.accessSync(path, fs.constants.R_OK | fs.constants.W_OK);
} catch (err) {
throw new Error(
'Cannot read/write to storage file for Home Assistant nodes',
);
} catch (errFirst) {
// Actually test if there's no permissions, for NFS environments
// See: https://github.com/nodejs/node/issues/28656
const dateTime = new Date().getTime();
const filePath = `${path}/tmp_${dateTime}.test`;
try {
const content = `NodeRed ${PACKAGE_NAME} ${dateTime}`;

fs.writeFileSync(filePath, content);
const readContent = fs.readFileSync(filePath, 'utf8');
if (readContent !== content) {
throw new Error('Content mismatch');
}
fs.unlinkSync(filePath);
} catch (err) {
console.error({ filePath }, err);
throw new Error(
`Cannot read/write to storage file for Home Assistant nodes`,
);
}
}

return true;
Expand Down