mirror of
https://github.com/marktext/marktext.git
synced 2025-05-02 19:59:41 +08:00
fix: watch rename syscall on Linux (#816)
This commit is contained in:
parent
b4784e83c5
commit
be3ea4b0ce
@ -1,11 +1,8 @@
|
||||
/**
|
||||
* Set `__static` path to static files in production
|
||||
* https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
|
||||
*/
|
||||
|
||||
// Set `__static` path to static files in production
|
||||
if (process.env.NODE_ENV !== 'development') {
|
||||
global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
|
||||
}
|
||||
|
||||
global.MARKTEXT_DEBUG = process.env.MARKTEXT_DEBUG || process.env.NODE_ENV !== 'production'
|
||||
global.MARKTEXT_DEBUG_VERBOSE = global.MARKTEXT_DEBUG && process.env.MARKTEXT_DEBUG_VERBOSE
|
||||
global.MARKTEXT_SAFE_MODE = false
|
||||
|
@ -4,6 +4,7 @@ import { promisify } from 'util'
|
||||
import chokidar from 'chokidar'
|
||||
import { getUniqueId, log, hasMarkdownExtension } from './utils'
|
||||
import { loadMarkdownFile } from './utils/filesystem'
|
||||
import { isLinux } from './config'
|
||||
|
||||
const EVENT_NAME = {
|
||||
dir: 'AGANI::update-object-tree',
|
||||
@ -102,8 +103,23 @@ class Watcher {
|
||||
.on('unlink', pathname => unlink(win, pathname, type))
|
||||
.on('addDir', pathname => addDir(win, pathname))
|
||||
.on('unlinkDir', pathname => unlinkDir(win, pathname))
|
||||
.on('raw', (event, path, details) => {
|
||||
if (global.MARKTEXT_DEBUG_VERBOSE) {
|
||||
console.log(event, path, details)
|
||||
}
|
||||
|
||||
// rename syscall on Linux (chokidar#591)
|
||||
if (isLinux && event === 'rename') {
|
||||
const { watchedPath } = details
|
||||
// Use the same watcher and re-watch the file.
|
||||
watcher.unwatch(watchedPath)
|
||||
watcher.add(watchedPath)
|
||||
}
|
||||
})
|
||||
.on('error', error => {
|
||||
log(`Watcher error: ${error}`)
|
||||
const msg = `Watcher error: ${error}`
|
||||
console.log(msg)
|
||||
log(msg)
|
||||
})
|
||||
|
||||
this.watchers[id] = {
|
||||
|
@ -635,6 +635,8 @@ const actions = {
|
||||
|
||||
LISTEN_FOR_FILE_CHANGE ({ commit, state, rootState }) {
|
||||
ipcRenderer.on('AGANI::update-file', (e, { type, change }) => {
|
||||
// TODO: Set `isSaved` to false.
|
||||
// TODO: A new "changed" notification from different files overwrite the old notification - the old notification disappears.
|
||||
if (type === 'unlink') {
|
||||
return notice.notify({
|
||||
title: 'File Removed on Disk',
|
||||
|
Loading…
Reference in New Issue
Block a user