Drop deleted story distribution lists after 30d
This commit is contained in:
parent
941304cd31
commit
373540a996
1 changed files with 37 additions and 3 deletions
|
@ -40,7 +40,7 @@ import * as durations from '../util/durations';
|
||||||
import { BackOff } from '../util/BackOff';
|
import { BackOff } from '../util/BackOff';
|
||||||
import { storageJobQueue } from '../util/JobQueue';
|
import { storageJobQueue } from '../util/JobQueue';
|
||||||
import { sleep } from '../util/sleep';
|
import { sleep } from '../util/sleep';
|
||||||
import { isMoreRecentThan } from '../util/timestamp';
|
import { isMoreRecentThan, isOlderThan } from '../util/timestamp';
|
||||||
import { map, filter } from '../util/iterables';
|
import { map, filter } from '../util/iterables';
|
||||||
import { ourProfileKeyService } from './ourProfileKey';
|
import { ourProfileKeyService } from './ourProfileKey';
|
||||||
import {
|
import {
|
||||||
|
@ -335,12 +335,35 @@ async function generateManifest(
|
||||||
`adding storyDistributionLists=${storyDistributionLists.length}`
|
`adding storyDistributionLists=${storyDistributionLists.length}`
|
||||||
);
|
);
|
||||||
|
|
||||||
storyDistributionLists.forEach(storyDistributionList => {
|
for (const storyDistributionList of storyDistributionLists) {
|
||||||
const storageRecord = new Proto.StorageRecord();
|
const storageRecord = new Proto.StorageRecord();
|
||||||
storageRecord.storyDistributionList = toStoryDistributionListRecord(
|
storageRecord.storyDistributionList = toStoryDistributionListRecord(
|
||||||
storyDistributionList
|
storyDistributionList
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (
|
||||||
|
storyDistributionList.deletedAtTimestamp != null &&
|
||||||
|
isOlderThan(storyDistributionList.deletedAtTimestamp, durations.MONTH)
|
||||||
|
) {
|
||||||
|
const droppedID = storyDistributionList.storageID;
|
||||||
|
const droppedVersion = storyDistributionList.storageVersion;
|
||||||
|
if (!droppedID) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const recordID = redactStorageID(droppedID, droppedVersion);
|
||||||
|
|
||||||
|
log.warn(
|
||||||
|
`storageService.generateManifest(${version}): ` +
|
||||||
|
`dropping storyDistributionList=${recordID} ` +
|
||||||
|
`due to expired deleted timestamp=${storyDistributionList.deletedAtTimestamp}`
|
||||||
|
);
|
||||||
|
deleteKeys.add(droppedID);
|
||||||
|
|
||||||
|
drop(dataInterface.deleteStoryDistribution(storyDistributionList.id));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const { isNewItem, storageID } = processStorageRecord({
|
const { isNewItem, storageID } = processStorageRecord({
|
||||||
currentStorageID: storyDistributionList.storageID,
|
currentStorageID: storyDistributionList.storageID,
|
||||||
currentStorageVersion: storyDistributionList.storageVersion,
|
currentStorageVersion: storyDistributionList.storageVersion,
|
||||||
|
@ -359,7 +382,7 @@ async function generateManifest(
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
log.info(
|
log.info(
|
||||||
`storageService.upload(${version}): ` +
|
`storageService.upload(${version}): ` +
|
||||||
|
@ -587,6 +610,17 @@ async function generateManifest(
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Save pending deletes until we have a confirmed upload
|
||||||
|
await window.storage.put(
|
||||||
|
'storage-service-pending-deletes',
|
||||||
|
// Note: `deleteKeys` already includes the prev value of
|
||||||
|
// 'storage-service-pending-deletes'
|
||||||
|
Array.from(deleteKeys, storageID => ({
|
||||||
|
storageID,
|
||||||
|
storageVersion: version,
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
|
||||||
if (deleteKeys.size !== pendingDeletes.size) {
|
if (deleteKeys.size !== pendingDeletes.size) {
|
||||||
const localDeletes = Array.from(deleteKeys).map(key =>
|
const localDeletes = Array.from(deleteKeys).map(key =>
|
||||||
redactStorageID(key)
|
redactStorageID(key)
|
||||||
|
|
Loading…
Add table
Reference in a new issue