|
|
@ -80,7 +80,6 @@ class FileProvider { |
|
|
|
async _exists (path) { |
|
|
|
async _exists (path) { |
|
|
|
path = this.getPathFromUrl(path) || path // ensure we actually use the normalized path from here
|
|
|
|
path = this.getPathFromUrl(path) || path // ensure we actually use the normalized path from here
|
|
|
|
var unprefixedpath = this.removePrefix(path) |
|
|
|
var unprefixedpath = this.removePrefix(path) |
|
|
|
console.log(this.addSlash(unprefixedpath)) |
|
|
|
|
|
|
|
return path === this.type ? true : await window.remixFileSystem.exists(this.addSlash(unprefixedpath)) |
|
|
|
return path === this.type ? true : await window.remixFileSystem.exists(this.addSlash(unprefixedpath)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -103,8 +102,8 @@ class FileProvider { |
|
|
|
|
|
|
|
|
|
|
|
async set (path, content, cb) { |
|
|
|
async set (path, content, cb) { |
|
|
|
var unprefixedpath = this.removePrefix(path) |
|
|
|
var unprefixedpath = this.removePrefix(path) |
|
|
|
const exists = await window.remixFileSystem.exists(unprefixedpath) |
|
|
|
const exists = await window.remixFileSystem.exists(this.addSlash(unprefixedpath)) |
|
|
|
if (exists && await window.remixFileSystem.readFile(unprefixedpath, 'utf8') === content) { |
|
|
|
if (exists && await window.remixFileSystem.readFile(this.addSlash(unprefixedpath), 'utf8') === content) { |
|
|
|
if (cb) cb() |
|
|
|
if (cb) cb() |
|
|
|
return null |
|
|
|
return null |
|
|
|
} |
|
|
|
} |
|
|
@ -117,9 +116,9 @@ class FileProvider { |
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
if (!exists) { |
|
|
|
if (!exists) { |
|
|
|
this.event.emit('fileAdded', this._normalizePath(unprefixedpath), false) |
|
|
|
this.event.emit('fileAdded', this._normalizePath(this.addSlash(unprefixedpath)), false) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.event.emit('fileChanged', this._normalizePath(unprefixedpath)) |
|
|
|
this.event.emit('fileChanged', this._normalizePath(this.addSlash(unprefixedpath))) |
|
|
|
} |
|
|
|
} |
|
|
|
if (cb) cb() |
|
|
|
if (cb) cb() |
|
|
|
return true |
|
|
|
return true |
|
|
@ -181,13 +180,13 @@ class FileProvider { |
|
|
|
if (items.length !== 0) { |
|
|
|
if (items.length !== 0) { |
|
|
|
for (const item of items) { |
|
|
|
for (const item of items) { |
|
|
|
const curPath = `${path}${path.endsWith('/') ? '' : '/'}${item}` |
|
|
|
const curPath = `${path}${path.endsWith('/') ? '' : '/'}${item}` |
|
|
|
if ((await window.remixFileSystem.statExtended(curPath)).isDirectory()) { // delete folder
|
|
|
|
if ((await window.remixFileSystem.statExtended(this.addSlash(curPath))).isDirectory()) { // delete folder
|
|
|
|
await this.remove(curPath) |
|
|
|
await this.remove(curPath) |
|
|
|
} else { // delete file
|
|
|
|
} else { // delete file
|
|
|
|
await this.removeFile(curPath) |
|
|
|
await this.removeFile(curPath) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (await window.remixFileSystem.readdir(this.addSlash(path)).length === 0) await window.remixFileSystem.rmdir(path) |
|
|
|
await window.remixFileSystem.rmdir(this.addSlash(path)) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// folder is empty
|
|
|
|
// folder is empty
|
|
|
|
await window.remixFileSystem.rmdir(this.addSlash(path)) |
|
|
|
await window.remixFileSystem.rmdir(this.addSlash(path)) |
|
|
|