Changed logic for file/dir exists to use file provider

pull/4/head
ioedeveloper 5 years ago
parent 4e3b8d1b98
commit df91b9237f
  1. 6
      src/app/files/fileManager.js
  2. 5
      src/app/files/fileProvider.js

@ -120,7 +120,11 @@ class FileManager extends Plugin {
*/ */
exists (path) { exists (path) {
const provider = this.fileProviderOf(path) const provider = this.fileProviderOf(path)
return provider ? true : false // eslint-disable-line
return provider.exists(path, (err, result) => {
if (err) return false
return result
})
} }
/** /**

@ -66,12 +66,12 @@ class FileProvider {
exists (path, cb) { exists (path, cb) {
// todo check the type (directory/file) as well #2386 // todo check the type (directory/file) as well #2386
// currently it is not possible to have a file and folder with same path // currently it is not possible to have a file and folder with same path
cb(null, this._exists(path)) return cb(null, this._exists(path))
} }
_exists (path) { _exists (path) {
var unprefixedpath = this.removePrefix(path) var unprefixedpath = this.removePrefix(path)
return window.remixFileSystem.existsSync(unprefixedpath) return path === this.type ? true : window.remixFileSystem.existsSync(unprefixedpath)
} }
init (cb) { init (cb) {
@ -79,6 +79,7 @@ class FileProvider {
} }
get (path, cb) { get (path, cb) {
console.log('window.remixFileSystem: ', window.remixFileSystem)
cb = cb || function () {} cb = cb || function () {}
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)

Loading…
Cancel
Save