diff --git a/package.json b/package.json index b842c4ae1..23c476dac 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "trilium", "productName": "Trilium Notes", "description": "Trilium Notes", - "version": "0.32.3", + "version": "0.32.4", "license": "AGPL-3.0-only", "main": "electron.js", "bin": { diff --git a/src/public/javascripts/dialogs/branch_prefix.js b/src/public/javascripts/dialogs/branch_prefix.js index ef8f77b57..152a3c526 100644 --- a/src/public/javascripts/dialogs/branch_prefix.js +++ b/src/public/javascripts/dialogs/branch_prefix.js @@ -21,7 +21,7 @@ async function showDialog() { branchId = currentNode.data.branchId; const branch = await treeCache.getBranch(branchId); - $treePrefixInput.val(branch.prefix).focus(); + $treePrefixInput.val(branch.prefix); const noteTitle = await treeUtils.getNoteTitle(currentNode.data.noteId); @@ -46,6 +46,8 @@ $form.submit(() => { return false; }); +$dialog.on('shown.bs.modal', () => $treePrefixInput.focus()); + export default { showDialog }; \ No newline at end of file diff --git a/src/services/build.js b/src/services/build.js index fc97035b2..00ab27bba 100644 --- a/src/services/build.js +++ b/src/services/build.js @@ -1 +1 @@ -module.exports = { buildDate:"2019-06-02T14:04:32+02:00", buildRevision: "fbfb7b3b306d48ba9e7c09b7218af7354c58a3d1" }; +module.exports = { buildDate:"2019-06-05T22:53:34+02:00", buildRevision: "97a258c0c61177f7a3578f41691d2bd9a600f5b8" }; diff --git a/src/services/import/single.js b/src/services/import/single.js index 578187efe..1fb682421 100644 --- a/src/services/import/single.js +++ b/src/services/import/single.js @@ -47,8 +47,46 @@ const CODE_MIME_TYPES = { 'text/x-yaml': true }; +// extensions missing in mime-db +const EXTENSION_TO_MIME = { + ".cs": "text/x-csharp", + ".clj": "text/x-clojure", + ".erl": "text/x-erlang", + ".hrl": "text/x-erlang", + ".feature": "text/x-feature", + ".go": "text/x-go", + ".groovy": "text/x-groovy", + ".hs": "text/x-haskell", + ".lhs": "text/x-haskell", + ".http": "message/http", + ".kt": "text/x-kotlin", + ".m": "text/x-objectivec", + ".py": "text/x-python", + ".rb": "text/x-ruby", + ".scala": "text/x-scala", + ".swift": "text/x-swift" +}; + +function getMime(fileName) { + if (fileName.toLowerCase() === 'dockerfile') { + return "text/x-dockerfile"; + } + + const ext = path.extname(fileName).toLowerCase(); + + console.log("EXT", ext); + + if (ext in EXTENSION_TO_MIME) { + console.log(EXTENSION_TO_MIME[ext]); + + return EXTENSION_TO_MIME[ext]; + } + + return mimeTypes.lookup(fileName); +} + async function importSingleFile(importContext, file, parentNote) { - const mime = mimeTypes.lookup(file.originalname); + const mime = getMime(file.originalname); if (importContext.textImportedAsText) { if (mime === 'text/html') { @@ -87,7 +125,7 @@ async function importFile(importContext, file, parentNote) { target: 'into', isProtected: parentNote.isProtected && protectedSessionService.isProtectedSessionAvailable(), type: 'file', - mime: mimeTypes.lookup(originalName), + mime: getMime(originalName), attributes: [ { type: "label", name: "originalFileName", value: originalName }, { type: "label", name: "fileSize", value: size } @@ -102,7 +140,7 @@ async function importFile(importContext, file, parentNote) { async function importCodeNote(importContext, file, parentNote) { const title = getFileNameWithoutExtension(file.originalname); const content = file.buffer.toString("UTF-8"); - const detectedMime = mimeTypes.lookup(file.originalname); + const detectedMime = getMime(file.originalname); const mime = CODE_MIME_TYPES[detectedMime] === true ? detectedMime : CODE_MIME_TYPES[detectedMime]; const {note} = await noteService.createNote(parentNote.noteId, title, content, { diff --git a/src/services/setup.js b/src/services/setup.js index d06ec46e7..b56284316 100644 --- a/src/services/setup.js +++ b/src/services/setup.js @@ -5,6 +5,7 @@ const repository = require('./repository'); const optionService = require('./options'); const syncOptions = require('./sync_options'); const request = require('./request'); +const appInfo = require('./app_info'); async function hasSyncServerSchemaAndSeed() { const response = await requestToSyncServer('GET', '/api/setup/status'); @@ -27,7 +28,8 @@ async function sendSeedToSyncServer() { log.info("Initiating sync to server"); await requestToSyncServer('POST', '/api/setup/sync-seed', { - options: await getSyncSeedOptions() + options: await getSyncSeedOptions(), + syncVersion: appInfo.syncVersion }); // this is completely new sync, need to reset counters. If this would not be new sync, diff --git a/src/services/sync_table.js b/src/services/sync_table.js index d7b41e850..110db688f 100644 --- a/src/services/sync_table.js +++ b/src/services/sync_table.js @@ -62,26 +62,33 @@ async function cleanupSyncRowsForMissingEntities(entityName, entityKey) { } async function fillSyncRows(entityName, entityKey, condition = '') { - await cleanupSyncRowsForMissingEntities(entityName, entityKey); + try { + await cleanupSyncRowsForMissingEntities(entityName, entityKey); - const entityIds = await sql.getColumn(`SELECT ${entityKey} FROM ${entityName}` - + (condition ? ` WHERE ${condition}` : '')); + const entityIds = await sql.getColumn(`SELECT ${entityKey} FROM ${entityName}` + + (condition ? ` WHERE ${condition}` : '')); - for (const entityId of entityIds) { - const existingRows = await sql.getValue("SELECT COUNT(id) FROM sync WHERE entityName = ? AND entityId = ?", [entityName, entityId]); + for (const entityId of entityIds) { + const existingRows = await sql.getValue("SELECT COUNT(id) FROM sync WHERE entityName = ? AND entityId = ?", [entityName, entityId]); - // we don't want to replace existing entities (which would effectively cause full resync) - if (existingRows === 0) { - log.info(`Creating missing sync record for ${entityName} ${entityId}`); + // we don't want to replace existing entities (which would effectively cause full resync) + if (existingRows === 0) { + log.info(`Creating missing sync record for ${entityName} ${entityId}`); - await sql.insert("sync", { - entityName: entityName, - entityId: entityId, - sourceId: "SYNC_FILL", - utcSyncDate: dateUtils.utcNowDateTime() - }); + await sql.insert("sync", { + entityName: entityName, + entityId: entityId, + sourceId: "SYNC_FILL", + utcSyncDate: dateUtils.utcNowDateTime() + }); + } } } + catch (e) { + // this is to fix migration from 0.30 to 0.32, can be removed later + // see https://github.com/zadam/trilium/issues/557 + log.error(`Filling sync rows failed for ${entityName} ${entityKey} with error "${e.message}", continuing`); + } } async function fillAllSyncRows() {