mirror of
https://github.com/enso-org/enso.git
synced 2024-12-27 03:52:35 +03:00
Better workaround for missing root folder. (#11046)
With the changes for asset directory the auto-creation condition was failing. This should make it work again.
This commit is contained in:
parent
a0a4a2fef3
commit
a33376c8d7
@ -139,16 +139,12 @@ export default class LocalBackend extends Backend {
|
||||
): Promise<readonly backend.AnyAsset[]> {
|
||||
const parentIdRaw = query.parentId == null ? null : extractTypeAndId(query.parentId).id
|
||||
const parentId = query.parentId ?? newDirectoryId(this.projectManager.rootDirectory)
|
||||
// Check if Root Directory Exists
|
||||
if (
|
||||
parentIdRaw == null &&
|
||||
!(await this.projectManager.exists(this.projectManager.rootDirectory))
|
||||
) {
|
||||
await this.projectManager.createDirectory(this.projectManager.rootDirectory)
|
||||
return []
|
||||
} else {
|
||||
|
||||
// Catch the case where the directory does not exist.
|
||||
let result: backend.AnyAsset[] = []
|
||||
try {
|
||||
const entries = await this.projectManager.listDirectory(parentIdRaw)
|
||||
return entries
|
||||
result = entries
|
||||
.map((entry) => {
|
||||
switch (entry.type) {
|
||||
case projectManager.FileSystemEntryType.DirectoryEntry: {
|
||||
@ -198,7 +194,21 @@ export default class LocalBackend extends Backend {
|
||||
}
|
||||
})
|
||||
.sort(backend.compareAssets)
|
||||
} catch (error) {
|
||||
// Failed so check if exists
|
||||
if (!(await this.projectManager.exists(parentIdRaw))) {
|
||||
if (parentIdRaw === this.projectManager.rootDirectory) {
|
||||
// Auto create the root directory
|
||||
await this.projectManager.createDirectory(this.projectManager.rootDirectory)
|
||||
result = []
|
||||
} else {
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
throw new Error('Directory does not exist.')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
/** Return a list of projects belonging to the current user.
|
||||
|
Loading…
Reference in New Issue
Block a user