Compare commits

..

No commits in common. "3f64369852e646b1e1bf2bd60a7da081f447b2c6" and "63ee4ce7192e35e550b40d1a798306a7c07b505c" have entirely different histories.

2 changed files with 9 additions and 19 deletions

View File

@ -668,16 +668,9 @@ export default class Services {
for (const hash of apiReturn.push_to_storage) { for (const hash of apiReturn.push_to_storage) {
const blob = await this.getBlobFromDb(hash); const blob = await this.getBlobFromDb(hash);
if (blob) { if (blob) {
// Get the storages from the diff data await this.saveDataToStorage(hash, blob, null);
const diff = await this.getDiffByValueFromDb(hash);
if (diff) {
const storages = diff.storages;
await this.saveDataToStorage(hash, storages, blob, null);
} else { } else {
console.error('Failed to get diff from db for hash', hash); console.error('Failed to get data from db');
}
} else {
console.error('Failed to get data from db for hash', hash);
} }
} }
} }
@ -1037,7 +1030,9 @@ export default class Services {
} }
} }
public async saveDataToStorage(hash: string, storages: string[], data: Blob, ttl: number | null) { public async saveDataToStorage(hash: string, data: Blob, ttl: number | null) {
const storages = [STORAGEURL];
try { try {
await storeData(storages, hash, data, ttl); await storeData(storages, hash, data, ttl);
} catch (e) { } catch (e) {
@ -1057,12 +1052,6 @@ export default class Services {
return await testData(storages, hash); return await testData(storages, hash);
} }
public async getDiffByValueFromDb(hash: string): Promise<UserDiff | null> {
const db = await Database.getInstance();
const diff = await db.getObject('diffs', hash);
return diff;
}
public async saveDiffsToDb(diffs: UserDiff[]) { public async saveDiffsToDb(diffs: UserDiff[]) {
const db = await Database.getInstance(); const db = await Database.getInstance();
try { try {

View File

@ -7,13 +7,14 @@ export async function storeData(servers: string[], key: string, value: Blob, ttl
let url: string; let url: string;
if (server.startsWith('/')) { if (server.startsWith('/')) {
// Relative path - construct manually for proxy // Relative path - construct manually for proxy
url = `${server}/store/${encodeURIComponent(key)}`; url = `${server}/store?key=${encodeURIComponent(key)}`;
if (ttl !== null) { if (ttl !== null) {
url += `?ttl=${ttl}`; url += `&ttl=${ttl}`;
} }
} else { } else {
// Absolute URL - use URL constructor // Absolute URL - use URL constructor
const urlObj = new URL(`${server}/store/${encodeURIComponent(key)}`); const urlObj = new URL(`${server}/store`);
urlObj.searchParams.append('key', key);
if (ttl !== null) { if (ttl !== null) {
urlObj.searchParams.append('ttl', ttl.toString()); urlObj.searchParams.append('ttl', ttl.toString());
} }