Merge branch 'stable'

# Conflicts:
#	package-lock.json
This commit is contained in:
zadam 2019-06-06 21:24:25 +02:00
commit 1f3d726048
6 changed files with 70 additions and 21 deletions

View file

@ -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": {

View file

@ -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
};

View file

@ -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" };

View file

@ -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, {

View file

@ -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,

View file

@ -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() {