check file content only if file exist

pull/1/head
yann300 5 years ago committed by LianaHus
parent 5b2f422c63
commit 2c0e911ef1
  1. 3
      src/app/files/fileProvider.js

@ -84,6 +84,8 @@ class FileProvider {
cb = cb || function () {} cb = cb || function () {}
var unprefixedpath = this.removePrefix(path) var unprefixedpath = this.removePrefix(path)
var exists = window.remixFileSystem.existsSync(unprefixedpath) var exists = window.remixFileSystem.existsSync(unprefixedpath)
if (exists && window.remixFileSystem.readFileSync(unprefixedpath, 'utf8') === content) return true
if (!exists && unprefixedpath.indexOf('/') !== -1) { if (!exists && unprefixedpath.indexOf('/') !== -1) {
const paths = unprefixedpath.split('/') const paths = unprefixedpath.split('/')
paths.pop() // last element should the filename paths.pop() // last element should the filename
@ -98,7 +100,6 @@ class FileProvider {
}) })
} }
try { try {
if (window.remixFileSystem.readFileSync(unprefixedpath, 'utf8') === content) return true
window.remixFileSystem.writeFileSync(unprefixedpath, content) window.remixFileSystem.writeFileSync(unprefixedpath, content)
} catch (e) { } catch (e) {
cb(e) cb(e)

Loading…
Cancel
Save