-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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
show symbolic links as decorations in explorer #43815
Changes from all commits
40b7a64
e3a88e9
48daad5
92e7f72
6ec78d6
5e23401
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -912,8 +912,8 @@ export class FileService implements IFileService { | |
private toStatResolver(resource: uri): TPromise<StatResolver> { | ||
const absolutePath = this.toAbsolutePath(resource); | ||
|
||
return pfs.stat(absolutePath).then(stat => { | ||
return new StatResolver(resource, stat.isDirectory(), stat.mtime.getTime(), stat.size, this.options.verboseLogging ? this.options.errorLogger : void 0); | ||
return pfs.statLink(absolutePath).then(({ isSymbolicLink, stat }) => { | ||
return new StatResolver(resource, isSymbolicLink, stat.isDirectory(), stat.mtime.getTime(), stat.size, this.options.verboseLogging ? this.options.errorLogger : void 0); | ||
}); | ||
} | ||
|
||
|
@@ -1146,25 +1146,21 @@ export class FileService implements IFileService { | |
} | ||
|
||
export class StatResolver { | ||
private resource: uri; | ||
private isDirectory: boolean; | ||
private mtime: number; | ||
private name: string; | ||
private etag: string; | ||
private size: number; | ||
private errorLogger: (error: Error | string) => void; | ||
|
||
constructor(resource: uri, isDirectory: boolean, mtime: number, size: number, errorLogger?: (error: Error | string) => void) { | ||
constructor( | ||
private resource: uri, | ||
private isSymbolicLink: boolean, | ||
private isDirectory: boolean, | ||
private mtime: number, | ||
private size: number, | ||
private errorLogger?: (error: Error | string) => void | ||
) { | ||
assert.ok(resource && resource.scheme === Schemas.file, `Invalid resource: ${resource}`); | ||
|
||
this.resource = resource; | ||
this.isDirectory = isDirectory; | ||
this.mtime = mtime; | ||
this.name = getBaseLabel(resource); | ||
this.etag = etag(size, mtime); | ||
this.size = size; | ||
|
||
this.errorLogger = errorLogger; | ||
} | ||
|
||
public resolve(options: IResolveFileOptions): TPromise<IFileStat> { | ||
|
@@ -1173,6 +1169,7 @@ export class StatResolver { | |
const fileStat: IFileStat = { | ||
resource: this.resource, | ||
isDirectory: this.isDirectory, | ||
isSymbolicLink: this.isSymbolicLink, | ||
name: this.name, | ||
etag: this.etag, | ||
size: this.size, | ||
|
@@ -1223,6 +1220,7 @@ export class StatResolver { | |
flow.parallel(files, (file: string, clb: (error: Error, children: IFileStat) => void) => { | ||
const fileResource = uri.file(paths.resolve(absolutePath, file)); | ||
let fileStat: fs.Stats; | ||
let isSymbolicLink = false; | ||
const $this = this; | ||
|
||
flow.sequence( | ||
|
@@ -1235,7 +1233,10 @@ export class StatResolver { | |
}, | ||
|
||
function stat(this: any): void { | ||
fs.stat(fileResource.fsPath, this); | ||
extfs.statLink(fileResource.fsPath, (error: Error, statAndIsLink) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be nicer: extfs.statLink(fileResource.fsPath, (error: Error, { stat, isSymbolicLink }) => {
isSymbolicLink = isSymbolicLink;
this(null, stat);
}); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did not do this due to name clash of the isSymoblicLink variable a couple of lines up. Decided to leave like it is. |
||
isSymbolicLink = statAndIsLink.isSymbolicLink; | ||
this(null, statAndIsLink.stat); | ||
}); | ||
}, | ||
|
||
function countChildren(this: any, fsstat: fs.Stats): void { | ||
|
@@ -1254,6 +1255,7 @@ export class StatResolver { | |
const childStat: IFileStat = { | ||
resource: fileResource, | ||
isDirectory: fileStat.isDirectory(), | ||
isSymbolicLink, | ||
name: file, | ||
mtime: fileStat.mtime.getTime(), | ||
etag: etag(fileStat), | ||
|
@@ -1293,4 +1295,4 @@ export class StatResolver { | |
}); | ||
}); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ function create(relativePath: string): StatResolver { | |
let absolutePath = relativePath ? path.join(basePath, relativePath) : basePath; | ||
let fsStat = fs.statSync(absolutePath); | ||
|
||
return new StatResolver(uri.file(absolutePath), fsStat.isDirectory(), fsStat.mtime.getTime(), fsStat.size, void 0); | ||
return new StatResolver(uri.file(absolutePath), fsStat.isSymbolicLink(), fsStat.isDirectory(), fsStat.mtime.getTime(), fsStat.size, void 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @isidorn can we have a test for this too? it looks like node.js allows to create symlinks ( |
||
} | ||
|
||
function toResource(relativePath: string): uri { | ||
|
@@ -183,4 +183,4 @@ suite('Stat Resolver', () => { | |
}) | ||
.done(() => done(), done); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@isidorn why is this method not simply using
extfs
? E.g. it should be as simple as:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bpasero you are correct. I was not aware I can depend on
extfs
inpfs
, but now I see it is already done.Fixed