download PermissionDenied. make file writable after copy to cache
milahu opened this issue · 2 comments
milahu commented
Lines 255 to 259 in 7e85fa9
when the source file is read-only (chmod 0555)
then the cached file is also read-only
future calls to download fail
because the target file in cache is read-only
first call:
Copying file:///tmp/tmp.aGowOqCn9e/vscode/vscode-deno/libwebview.so
second call:
Copying file:///tmp/tmp.aGowOqCn9e/vscode/vscode-deno/libwebview.so
error: Uncaught (in promise) PermissionDenied: Permission denied (os error 13), copy '/tmp/tmp.aGowOqCn9e/vscode/vscode-deno/libwebview.so' -> '/home/user/.cache/deno/plug/file/a8eb18dc8f0f8199d82db2f57b5f04a3f527e44095eca509c3960f4760b36e4e.so'
await Deno.copyFile(fromFileUrl(url), cacheFilePath);
^
at async Object.copyFile (deno:runtime/js/30_fs.js:64:5)
at async download (https://deno.land/x/plug@1.0.0-rc.3/download.ts:257:9)
at async dlopen (https://deno.land/x/plug@1.0.0-rc.3/mod.ts:145:22)
at async file:///tmp/tmp.aGowOqCn9e/vscode/vscode-deno/webview_deno/src/ffi.ts:154:20
called from https://deno.land/x/webview
discuss: should preserve the execution bit of the original file? or just chmod 0644
all files?
milahu commented
case "file:": {
console.log(`${colors.green("Copying")} ${url}`);
/*
// Deno.chmod currently throws on Windows
await Deno.copyFile(fromFileUrl(url), cacheFilePath);
await Deno.chmod(cacheFilePath, 0o644);
*/
// portable workaround
// note: this is limited by memory size
// todo: copy large file in chunks
const data = await Deno.readFile(fromFileUrl(url));
await Deno.writeFile(cacheFilePath, data);
break;
}
merged in https://github.com/milahu/plug
eliassjogreen commented
Interesting, I will look into this later but I think the easiest solution is just to do chmod 0o644 on posix.