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

Handle readonly files #199

Closed
5 tasks
akosyakov opened this issue Jun 13, 2017 · 8 comments · Fixed by #11965 or #12354
Closed
5 tasks

Handle readonly files #199

akosyakov opened this issue Jun 13, 2017 · 8 comments · Fixed by #11965 or #12354
Labels
filesystem issues related to the filesystem help wanted issues meant to be picked up, require help

Comments

@akosyakov
Copy link
Member

  • FileStat should have access flags. There should be utility methods to check flags on read, write and execute access
  • FileTreeModel should mark file stat nodes without read access as invisible
  • Resource should have an explicit optional isReadonly property with default based on the presence of Resource.save method. There should be a utility function to check it.
  • FileResource should use FileStat flags to implement isReadonly property
  • editor providers should use Resource.isReadonly(resource) to mark editors readonly or not
@hexa00
Copy link

hexa00 commented Jun 13, 2017

I disagree that some files should be invisible you have the right to see them... but an error should be thrown when you try to open ?

@akosyakov
Copy link
Member Author

I meant if the user doesn't have rights to see them he should not see them.

@hexa00
Copy link

hexa00 commented Jun 13, 2017

Then it's the directory that does not have read access and thus you won't be able to get to the file at all...

Otherwise I can see a no permission file with ls without any problems:
---------- 1 x x 0 Jun 13 08:22 testfi

@akosyakov akosyakov added the help wanted issues meant to be picked up, require help label Aug 29, 2017
@akosyakov
Copy link
Member Author

PRs are welcomed.

@epatpol
Copy link
Contributor

epatpol commented May 2, 2018

Would you rather have the fs.modes for the filestat (i.e bitmasks) or easier API like Filestat.isReadable: boolean, isWriteable, isExecutable and so on? Like so:

export interface FileStat {

    /**
     * The uri of the file.
     */
    uri: string;

    /**
     * File access
     */
    isReadable: boolean;
    isWriteable: boolean;
    isExecutable: boolean;

    /**
     * The last modification of this file.
     */
    lastModification: number;

    /**
     * The resource is a directory. Iff {{true}}
     * {{encoding}} has no meaning.
     */
    isDirectory: boolean;

    /**
     * The children of the file stat.
     * If it is undefined and isDirectory is true, then this file stat is unresolved.
     */
    children?: FileStat[];

    /**
     * The size of the file if known.
     */
    size?: number;
}

@akosyakov
Copy link
Member Author

@epatpol Could you check how VS Code handle it? They don't seem to expose such apis, maybe we are overthinking it.

@epatpol epatpol removed their assignment May 16, 2018
@vince-fugnitto vince-fugnitto added the filesystem issues related to the filesystem label Feb 27, 2020
@dpetroff
Copy link

In theia 1.36, I set some files to read only on the file system with chmod, and all the resource, filestat, etc. properties all still say that it's not read-only.

It looks to me like DiskFileSystemProvider is entirely oblivious of file permissions:

async stat(resource: URI): Promise<Stat> {
try {
const { stat, symbolicLink } = await this.statLink(this.toFilePath(resource)); // cannot use fs.stat() here to support links properly
return {
type: this.toType(stat, symbolicLink),
ctime: stat.birthtime.getTime(), // intentionally not using ctime here, we want the creation time
mtime: stat.mtime.getTime(),
size: stat.size
};
} catch (error) {
throw this.toFileSystemProviderError(error);
}
}

I think this issue should be reopened.

@msujew
Copy link
Member

msujew commented Apr 27, 2023

This issue will be resolved by #12354 instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
filesystem issues related to the filesystem help wanted issues meant to be picked up, require help
Projects
None yet
6 participants