mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fix blobIds - they shouldn't contain + and / characters
This commit is contained in:
parent
bd22863bb7
commit
72122d0f95
14
db/migrations/0224__fix_blobIds.sql
Normal file
14
db/migrations/0224__fix_blobIds.sql
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
UPDATE blobs SET blobId = REPLACE(blobId, '+', 'X');
|
||||||
|
UPDATE blobs SET blobId = REPLACE(blobId, '/', 'Y');
|
||||||
|
|
||||||
|
UPDATE notes SET blobId = REPLACE(blobId, '+', 'X');
|
||||||
|
UPDATE notes SET blobId = REPLACE(blobId, '/', 'Y');
|
||||||
|
|
||||||
|
UPDATE attachments SET blobId = REPLACE(blobId, '+', 'X');
|
||||||
|
UPDATE attachments SET blobId = REPLACE(blobId, '/', 'Y');
|
||||||
|
|
||||||
|
UPDATE revisions SET blobId = REPLACE(blobId, '+', 'X');
|
||||||
|
UPDATE revisions SET blobId = REPLACE(blobId, '/', 'Y');
|
||||||
|
|
||||||
|
UPDATE entity_changes SET entityId = REPLACE(blobId, '+', 'X') WHERE entityName = 'blobs';
|
||||||
|
UPDATE entity_changes SET entityId = REPLACE(blobId, '/', 'Y') WHERE entityName = 'blobs';
|
@ -4,8 +4,8 @@ const build = require('./build');
|
|||||||
const packageJson = require('../../package');
|
const packageJson = require('../../package');
|
||||||
const {TRILIUM_DATA_DIR} = require('./data_dir');
|
const {TRILIUM_DATA_DIR} = require('./data_dir');
|
||||||
|
|
||||||
const APP_DB_VERSION = 223;
|
const APP_DB_VERSION = 224;
|
||||||
const SYNC_VERSION = 30;
|
const SYNC_VERSION = 31;
|
||||||
const CLIPPER_PROTOCOL_VERSION = "1.0";
|
const CLIPPER_PROTOCOL_VERSION = "1.0";
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -56,10 +56,9 @@ async function sync() {
|
|||||||
catch (e) {
|
catch (e) {
|
||||||
proxyToggle = !proxyToggle;
|
proxyToggle = !proxyToggle;
|
||||||
|
|
||||||
if (e.message &&
|
if (e.message?.includes('ECONNREFUSED') ||
|
||||||
(e.message.includes('ECONNREFUSED') ||
|
e.message?.includes('ERR_') || // node network errors
|
||||||
e.message.includes('ERR_') || // node network errors
|
e.message?.includes('Bad Gateway')) {
|
||||||
e.message.includes('Bad Gateway'))) {
|
|
||||||
|
|
||||||
ws.syncFailed();
|
ws.syncFailed();
|
||||||
|
|
||||||
|
@ -28,8 +28,13 @@ function hashedBlobId(content) {
|
|||||||
// sha512 is faster than sha256
|
// sha512 is faster than sha256
|
||||||
const base64Hash = crypto.createHash('sha512').update(content).digest('base64');
|
const base64Hash = crypto.createHash('sha512').update(content).digest('base64');
|
||||||
|
|
||||||
// 20 characters of base64 gives us 120 bit of entropy which is plenty enough
|
// we don't want such + and / in the IDs
|
||||||
return base64Hash.substr(0, 20);
|
const kindaBase62Hash = base64Hash
|
||||||
|
.replace('+', 'X')
|
||||||
|
.replace('/', 'Y');
|
||||||
|
|
||||||
|
// 20 characters of base62 gives us ~120 bit of entropy which is plenty enough
|
||||||
|
return kindaBase62Hash.substr(0, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
function toBase64(plainText) {
|
function toBase64(plainText) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user