Skip to content

Commit a18719a

Browse files
committed
fix permissions bug while overwriting file while uploading
1 parent e50e464 commit a18719a

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

navigator/components/FileUpload.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,14 @@ function uploadFile(file, destination) {
107107
// superuser test
108108
let superuser = undefined;
109109
try {
110-
await cockpit.script('DIRNAME="$(dirname "$1")"; mkdir -p "$DIRNAME" && test -d "$DIRNAME" -a -x "$DIRNAME" -a -w "$DIRNAME"', [destination], { err: "message", binary: true, superuser });
110+
await cockpit.script(`
111+
if test -e "$1"; then
112+
test -w "$1"
113+
else
114+
DIRNAME="$(dirname "$1")"
115+
mkdir -p "$DIRNAME" && test -d "$DIRNAME" -a -x "$DIRNAME" -a -w "$DIRNAME"
116+
fi
117+
`, [destination], { err: "message", binary: true, superuser });
111118
} catch (e) {
112119
console.error(e);
113120
superuser = 'try';

0 commit comments

Comments
 (0)