Skip to content

Commit

Permalink
refactor: DiskListObject (#338)
Browse files Browse the repository at this point in the history
  • Loading branch information
kukhariev authored May 7, 2021
1 parent c5b9ea9 commit 37dc4ee
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions packages/core/src/storages/disk-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export class DiskFile extends File {}

export interface DiskListObject {
name: string;
updated: Date;
}

export type DiskStorageOptions = BaseStorageOptions<DiskFile> & {
Expand Down Expand Up @@ -62,13 +61,10 @@ export class DiskStorage extends BaseStorage<DiskFile, DiskListObject> {

async get(prefix = ''): Promise<DiskListObject[]> {
const files = await getFiles(join(this.directory, prefix));
const props = async (path: string): Promise<DiskListObject> => ({
name: relative(this.directory, path).replace(/\\/g, '/'),
updated: (await fsp.stat(path)).mtime
const props = (path: string): DiskListObject => ({
name: relative(this.directory, path).replace(/\\/g, '/')
});
return Promise.all(
files.filter(name => extname(name) !== METAFILE_EXTNAME).map(path => props(path))
);
return files.filter(name => extname(name) !== METAFILE_EXTNAME).map(path => props(path));
}

async delete(name: string): Promise<DiskFile[]> {
Expand Down

0 comments on commit 37dc4ee

Please sign in to comment.