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

download PermissionDenied. make file writable after copy to cache #20

Closed
milahu opened this issue Oct 12, 2022 · 2 comments · Fixed by #22
Closed

download PermissionDenied. make file writable after copy to cache #20

milahu opened this issue Oct 12, 2022 · 2 comments · Fixed by #22

Comments

@milahu
Copy link

milahu commented Oct 12, 2022

plug/download.ts

Lines 255 to 259 in 7e85fa9

case "file:": {
console.log(`${colors.green("Copying")} ${url}`);
await Deno.copyFile(fromFileUrl(url), cacheFilePath);
break;
}

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
Copy link
Author

milahu commented Oct 13, 2022

      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
Copy link
Member

Interesting, I will look into this later but I think the easiest solution is just to do chmod 0o644 on posix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants