images update, sync since all time option, qdb write location fixes, lastUsersSync fixes

This commit is contained in:
mrfry
2023-04-27 09:13:39 +02:00
parent c295781b48
commit 434777125c
7 changed files with 79 additions and 45 deletions
+10 -5
View File
@@ -1,5 +1,5 @@
import { PeerInfo } from '../types/basicTypes'
import { paths } from './files'
import { files, paths, readAndValidateFile } from './files'
import { parseCookie, post } from './networkUtils'
import utils from './utils'
@@ -14,10 +14,15 @@ export function isPeerSameAs(peer1: PeerInfo, peer2: PeerInfo): boolean {
return peer1.host === peer2.host && peer1.port === peer2.port
}
export function updatePeersFile(
peers: PeerInfo[],
updatedPeer: PeerInfo
): void {
export function updatePeersFile(updatedPeer: PeerInfo): void {
const newVal = readAndValidateFile<PeerInfo[]>(files.peersFile)
let peers
if (newVal) {
peers = newVal
}
if (!peers)
throw new Error('Peers file was invalid while trying to update it!')
const updatedPeers = peers.map((x) => {
if (isPeerSameAs(updatedPeer, x)) {
return {