提交 245ce3ae 编写于 作者: B Benjamin Pasero

files - proper size for content

上级 bc0574de
......@@ -499,6 +499,14 @@ interface IBaseStat {
*/
name: string;
/**
* The size of the file.
*
* The value may or may not be resolved as
* it is optional.
*/
size?: number;
/**
* The last modifictaion date represented
* as millis from unix epoch.
......@@ -526,6 +534,7 @@ interface IBaseStat {
export interface IBaseStatWithMetadata extends IBaseStat {
mtime: number;
etag: string;
size: number;
}
/**
......@@ -548,14 +557,6 @@ export interface IFileStat extends IBaseStat {
* The children of the file stat or undefined if none.
*/
children?: IFileStat[];
/**
* The size of the file.
*
* The value may or may not be resolved as
* it is optional.
*/
size?: number;
}
export interface IFileStatWithMetadata extends IFileStat, IBaseStatWithMetadata {
......
......@@ -736,7 +736,9 @@ export class SimpleRemoteFileService implements IFileService {
// @ts-ignore
mtime: content.mtime,
// @ts-ignore
name: content.name
name: content.name,
// @ts-ignore
size: content.size
};
});
}
......@@ -860,7 +862,8 @@ function initFakeFileSystem(): void {
mtime: Date.now(),
isDirectory: true,
name: basename(workspaceResource.fsPath),
children: []
children: [],
size: 0
};
fileMap.set(root.resource, root);
......
......@@ -228,6 +228,7 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
etag: streamContent.etag,
encoding: streamContent.encoding,
isReadonly: streamContent.isReadonly,
size: streamContent.size,
value: ''
};
......@@ -279,6 +280,7 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
result.name = stat.name;
result.mtime = stat.mtime;
result.etag = stat.etag;
result.size = stat.size;
// Return early if resource is a directory
if (stat.isDirectory) {
......
......@@ -324,7 +324,8 @@ export class RemoteFileService extends FileService {
name: fileStat.name,
etag: fileStat.etag,
mtime: fileStat.mtime,
isReadonly: fileStat.isReadonly
isReadonly: fileStat.isReadonly,
size: fileStat.size
};
});
});
......@@ -418,6 +419,7 @@ export class RemoteFileService extends FileService {
value: '',
encoding: content.encoding,
etag: content.etag,
size: content.size,
mtime: content.mtime,
name: content.name,
resource: content.resource,
......
......@@ -270,6 +270,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
resource: this.resource,
name: basename(this.resource),
mtime: Date.now(),
size: 0,
etag: etag(Date.now(), 0),
value: createTextBufferFactory(''), /* will be filled later from backup */
encoding: this.fileService.encoding.getWriteEncoding(this.resource, this.preferredEncoding).encoding,
......@@ -349,6 +350,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
private loadWithContent(content: IRawTextContent, options?: ILoadOptions, backup?: URI): Promise<TextFileEditorModel> {
return this.doLoadWithContent(content, backup).then(model => {
// Telemetry: We log the fileGet telemetry event after the model has been loaded to ensure a good mimetype
const settingsType = this.getTypeIfSettings();
if (settingsType) {
......@@ -381,11 +383,10 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
resource: this.resource,
name: content.name,
mtime: content.mtime,
size: -1,
size: content.size,
etag: content.etag,
isDirectory: false,
isSymbolicLink: false,
children: undefined,
isReadonly: content.isReadonly
});
......
......@@ -109,16 +109,16 @@ export class TextFileService extends Disposable implements ITextFileService {
resolveTextContent(resource: URI, options?: IResolveContentOptions): Promise<IRawTextContent> {
return this.fileService.resolveStreamContent(resource, options).then(streamContent => {
return createTextBufferFactoryFromStream(streamContent.value).then(res => {
const r: IRawTextContent = {
return {
resource: streamContent.resource,
name: streamContent.name,
mtime: streamContent.mtime,
etag: streamContent.etag,
encoding: streamContent.encoding,
isReadonly: streamContent.isReadonly,
size: streamContent.size,
value: res
};
return r;
} as IRawTextContent;
});
});
}
......
......@@ -251,7 +251,8 @@ export class TestTextFileService extends TextFileService {
mtime: content.mtime,
etag: content.etag,
encoding: content.encoding,
value: createTextBufferFactory(content.value)
value: createTextBufferFactory(content.value),
size: content.value.length
};
});
}
......@@ -961,7 +962,8 @@ export class TestFileService implements IFileService {
etag: 'index.txt',
encoding: 'utf8',
mtime: Date.now(),
name: resources.basename(resource)
name: resources.basename(resource),
size: 1
});
}
......@@ -981,6 +983,7 @@ export class TestFileService implements IFileService {
etag: 'index.txt',
encoding: 'utf8',
mtime: Date.now(),
size: 1,
name: resources.basename(resource)
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册