Created
November 18, 2018 19:44
-
-
Save hawkeye64/6d6283607d8c4c74230eefeed99a6104 to your computer and use it in GitHub Desktop.
folderWatcherHandler function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
folderWatcherHandler: function (newFolder, oldFolder) { | |
if (oldFolder && this.watcher) { | |
this.watcher.close() | |
} | |
if (newFolder) { | |
// let backend know to statically serve files from this folder | |
ipcRenderer.send('folder', newFolder) | |
this.watcher = chokidar.watch(newFolder, { | |
depth: 0, | |
ignorePermissionErrors: true | |
}) | |
if (this.watcher) { | |
this.watcher.on('ready', () => { // initial scan done | |
// watch for additions | |
this.watcher.on('raw', (event, path, details) => { | |
this.$root.$emit('rescan-current-folder') | |
}) | |
}) | |
this.watcher.on('error', (error) => { // initial scan done | |
console.error(error) | |
}) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment