mirror of
https://github.com/zadam/trilium.git
synced 2025-11-13 16:55:50 +01:00
opened file change detection now useable on all note types
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
const protectedSessionService = require('../../services/protected_session');
|
||||
const repository = require('../../services/repository');
|
||||
const utils = require('../../services/utils');
|
||||
const log = require('../../services/log');
|
||||
const noteRevisionService = require('../../services/note_revisions');
|
||||
const tmp = require('tmp');
|
||||
const fs = require('fs');
|
||||
@@ -122,6 +123,8 @@ function saveToTmpDir(req) {
|
||||
fs.writeSync(tmpObj.fd, note.getContent());
|
||||
fs.closeSync(tmpObj.fd);
|
||||
|
||||
log.info(`Saved temporary file for note ${noteId} into ${tmpObj.name}`);
|
||||
|
||||
if (utils.isElectron()) {
|
||||
chokidar.watch(tmpObj.name).on('change', (path, stats) => {
|
||||
ws.sendMessageToAllClients({
|
||||
@@ -130,8 +133,6 @@ function saveToTmpDir(req) {
|
||||
lastModifiedMs: stats.atimeMs,
|
||||
filePath: tmpObj.name
|
||||
});
|
||||
|
||||
console.log(stats, path);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -285,6 +285,8 @@ function uploadModifiedFile(req) {
|
||||
return [404, `Note ${noteId} has not been found`];
|
||||
}
|
||||
|
||||
log.info(`Updating note ${noteId} with content from ${filePath}`);
|
||||
|
||||
noteRevisionService.createNoteRevision(note);
|
||||
|
||||
const fileContent = fs.readFileSync(filePath);
|
||||
|
||||
@@ -186,7 +186,7 @@ function register(app) {
|
||||
route(GET, '/api/notes/:noteId/download', [auth.checkApiAuthOrElectron], filesRoute.downloadFile);
|
||||
// this "hacky" path is used for easier referencing of CSS resources
|
||||
route(GET, '/api/notes/download/:noteId', [auth.checkApiAuthOrElectron], filesRoute.downloadFile);
|
||||
apiRoute(POST, '/api/notes/:noteId/saveToTmpDir', filesRoute.saveToTmpDir);
|
||||
apiRoute(POST, '/api/notes/:noteId/save-to-tmp-dir', filesRoute.saveToTmpDir);
|
||||
|
||||
apiRoute(GET, '/api/notes/:noteId/attributes', attributesRoute.getEffectiveNoteAttributes);
|
||||
apiRoute(POST, '/api/notes/:noteId/attributes', attributesRoute.addNoteAttribute);
|
||||
|
||||
Reference in New Issue
Block a user