From bb763435ef315826ec50a7a271f365333eb7491e Mon Sep 17 00:00:00 2001 From: Eric van der Vlist Date: Tue, 7 Mar 2023 18:41:05 +0100 Subject: [PATCH] Don't compact trksegs if you don't own them --- src/db-admin/health-legacy.ts | 1 + src/db/trkseg.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/db-admin/health-legacy.ts b/src/db-admin/health-legacy.ts index 710c84f..593da77 100644 --- a/src/db-admin/health-legacy.ts +++ b/src/db-admin/health-legacy.ts @@ -61,6 +61,7 @@ export const watchDbLegacy = async () => { const newState = { ...state(), dbName: status()?.dbInfo?.db_name, + userId: dbUrlToUserId(status()?.remoteDbInfo?.host), localUpdateSeq: status()?.dbInfo?.update_seq, remoteUrl: status()?.remoteDbInfo?.host, sync: syncState(), diff --git a/src/db/trkseg.ts b/src/db/trkseg.ts index 6b8714d..3eb0cd0 100644 --- a/src/db/trkseg.ts +++ b/src/db/trkseg.ts @@ -1,4 +1,5 @@ import { cloneDeep } from 'lodash'; +import { state } from '../db-admin/health-legacy'; import getUri, { intToTrkptId } from '../lib/ids'; import { appendToArray } from './gpx'; import { getFamily, put } from './lib'; @@ -43,7 +44,7 @@ export const getTrksegDocs: ({ export const getTrkseg = async (params: any) => { const { id } = params; const { docs, trkseg } = await getTrksegDocs(params); - if (docs.rows.length > 1) { + if (docs.rows.length > 1 && docs.rows[0].doc.origin === state().userId) { // console.log({ // caller: 'getTrkseg compactRteOrTrksegDebounced required', // id,