1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-24 08:12:24 +02:00

Desktop: Fixed potential crash when watching note files or resources

This commit is contained in:
Laurent Cozic 2020-11-27 11:08:42 +00:00
parent 72ccc90ea0
commit 011a65f73b
2 changed files with 12 additions and 4 deletions

View File

@ -81,7 +81,10 @@ export default class ExternalEditWatcher {
if (!this.chokidar_) return;
if (!this.watcher_) {
this.watcher_ = this.chokidar_.watch(fileToWatch);
this.watcher_ = this.chokidar_.watch(fileToWatch, {
useFsEvents: false,
});
this.watcher_.on('all', async (event: string, path: string) => {
this.logger().debug(`ExternalEditWatcher: Event: ${event}: ${path}`);

View File

@ -156,9 +156,14 @@ export default class ResourceEditWatcher {
};
if (!this.watcher_) {
this.watcher_ = this.chokidar_.watch(fileToWatch);
this.watcher_ = this.chokidar_.watch(fileToWatch, {
// Need to turn off fs-events because when it's on Chokidar
// keeps emitting "modified" events (on "raw" handler), several
// times per seconds, even when nothing is changed.
useFsEvents: false,
});
this.watcher_.on('all', (event: any, path: string) => {
path = toSystemSlashes(path, 'linux');
path = path ? toSystemSlashes(path, 'linux') : '';
this.logger().info(`ResourceEditWatcher: Event: ${event}: ${path}`);
@ -186,7 +191,7 @@ export default class ResourceEditWatcher {
//
// @ts-ignore Leave unused path variable
this.watcher_.on('raw', (event: string, path: string, options: any) => {
const watchedPath = toSystemSlashes(options.watchedPath, 'linux');
const watchedPath = options.watchedPath ? toSystemSlashes(options.watchedPath, 'linux') : '';
this.logger().debug(`ResourceEditWatcher: Raw event: ${event}: ${watchedPath}`);
if (event === 'rename') {