Skip to content

Commit

Permalink
fix(Filesystem): avoid directory already exists on append (#3629)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile committed Oct 13, 2020
1 parent 1c47e15 commit 249073d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions core/src/web/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,12 @@ export class FilesystemPluginWeb extends WebPlugin implements FilesystemPlugin {

let parentEntry = await this.dbRequest('get', [parentPath]) as EntryObj;
if (parentEntry === undefined) {
const parentArgPathIndex = parentPath.indexOf('/', 1);
const parentArgPath = parentArgPathIndex !== -1 ? parentPath.substr(parentArgPathIndex) : '/';
await this.mkdir({path: parentArgPath, directory: options.directory, recursive: true});
const subDirIndex = parentPath.indexOf('/', 1);
if (subDirIndex !== -1) {
const parentArgPath = parentPath.substr(subDirIndex);
await this.mkdir({path: parentArgPath, directory: options.directory, recursive: true});
}
}

if (occupiedEntry !== undefined) {
data = occupiedEntry.content + data;
ctime = occupiedEntry.ctime;
Expand Down

0 comments on commit 249073d

Please sign in to comment.