fix: testproj need to be with a dot

This commit is contained in:
reito
2024-11-14 00:59:02 +08:00
parent 8170c46042
commit 5d4f75b72e

View File

@@ -980,14 +980,14 @@ export class DatabaseUI extends DisposableObject {
byFolder: boolean, byFolder: boolean,
progress: ProgressCallback, progress: ProgressCallback,
): Promise<DatabaseItem | undefined> { ): Promise<DatabaseItem | undefined> {
if (byFolder && !uri.fsPath.endsWith("testproj")) { if (byFolder && !uri.fsPath.endsWith(".testproj")) {
const fixedUri = await this.fixDbUri(uri); const fixedUri = await this.fixDbUri(uri);
// we are selecting a database folder // we are selecting a database folder
return await this.databaseManager.openDatabase(fixedUri, { return await this.databaseManager.openDatabase(fixedUri, {
type: "folder", type: "folder",
}); });
} else { } else {
// we are selecting a database archive or a testproj. // we are selecting a database archive or a .testproj.
// Unzip archives (if an archive) and copy into a workspace-controlled area // Unzip archives (if an archive) and copy into a workspace-controlled area
// before importing. // before importing.
return await this.databaseFetcher.importLocalDatabase( return await this.databaseFetcher.importLocalDatabase(
@@ -1028,6 +1028,7 @@ export class DatabaseUI extends DisposableObject {
const databases: DatabaseItem[] = []; const databases: DatabaseItem[] = [];
const failures: string[] = []; const failures: string[] = [];
const entries = await workspace.fs.readDirectory(uri); const entries = await workspace.fs.readDirectory(uri);
const validFileTypes = [FileType.File, FileType.Directory];
for (const [index, entry] of entries.entries()) { for (const [index, entry] of entries.entries()) {
progress({ progress({
@@ -1044,10 +1045,19 @@ export class DatabaseUI extends DisposableObject {
}); });
}; };
if (!validFileTypes.includes(entry[1])) {
void this.app.logger.log(
`Skip import ${entry}, invalid FileType: ${entry[1]}`,
);
continue;
}
try { try {
const fixedUri = await this.fixDbUri(Uri.joinPath(uri, entry[0])); const databaseUri = Uri.joinPath(uri, entry[0]);
void this.app.logger.log(`Importing from ${databaseUri}`);
const database = await this.importDatabase( const database = await this.importDatabase(
fixedUri, databaseUri,
entry[1] === FileType.Directory, entry[1] === FileType.Directory,
subProgress, subProgress,
); );
@@ -1056,7 +1066,7 @@ export class DatabaseUI extends DisposableObject {
} else { } else {
failures.push(entry[0]); failures.push(entry[0]);
} }
} catch (e) { } catch {
failures.push(entry[0]); failures.push(entry[0]);
} }
} }