Skip to content

Commit

Permalink
Merge branch 'main' into qna-recognizer
Browse files Browse the repository at this point in the history
* main:
  fix: allow storage implementation to determine writability (#3630)
  fix: fix deploy issue because botproject files structure changed (#3719)
  fix: loop infinitely on publish page when get publish status (#3716)
  • Loading branch information
alanlong9278 committed Jul 28, 2020
2 parents 5a59387 + 9d20afb commit d247c5e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions Composer/packages/server/src/models/storage/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface StorageConnection {
export interface Stat {
isDir: boolean;
isFile: boolean;
isWritable: boolean;
lastModified: string;
size: string;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,17 @@ const rename = promisify(fs.rename);
export class LocalDiskStorage implements IFileStorage {
async stat(path: string): Promise<Stat> {
const fstat = await stat(path);
// test to see if this file is writable
let writable = true;
try {
fs.accessSync(path, fs.constants.W_OK);
} catch (err) {
writable = false;
}
return {
isDir: fstat.isDirectory(),
isFile: fstat.isFile(),
isWritable: writable,
lastModified: fstat.mtime.toString(),
size: fstat.isFile() ? fstat.size.toString() : '',
};
Expand Down
8 changes: 1 addition & 7 deletions Composer/packages/server/src/services/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,11 @@ class StorageService {
// TODO: fix this behavior and the upper layer interface accordingly
return JSON.parse(await storageClient.readFile(filePath));
} else {
let writable = true;
try {
fs.accessSync(filePath, fs.constants.W_OK);
} catch (err) {
writable = false;
}
return {
name: Path.basename(filePath),
parent: Path.dirname(filePath),
children: await this.getChildren(storageClient, filePath),
writable: writable,
writable: stat.isWritable,
};
}
};
Expand Down
4 changes: 4 additions & 0 deletions Composer/plugins/mongoStorage/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,15 @@ class MongoStorage implements IFileStorage {
isDir: true,
isFile: false,
lastModified: file.lastModified,
isWritable: true,
size: 1, // TODO: real size
});
} else {
resolve({
isDir: false,
isFile: true,
lastModified: file.lastModified,
isWritable: true,
size: 1, // TODO: real size
});
}
Expand All @@ -103,6 +105,7 @@ class MongoStorage implements IFileStorage {
isDir: true,
isFile: false,
lastModified: new Date(),
isWritable: true,
size: 0, // TODO: ??
});
} else {
Expand All @@ -113,6 +116,7 @@ class MongoStorage implements IFileStorage {
isDir: true,
isFile: false,
lastModified: file.lastModified,
isWritable: true,
size: 0, // TODO: ??
});
}
Expand Down
1 change: 1 addition & 0 deletions Composer/plugins/mongoStorage/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface StorageConnection {
export interface Stat {
isDir: boolean;
isFile: boolean;
isWritable: boolean;
lastModified: string;
size: string;
}
Expand Down

0 comments on commit d247c5e

Please sign in to comment.