Skip to content

Commit

Permalink
web/satellite: fix locked files calculation when pagination is enabled
Browse files Browse the repository at this point in the history
The problem is that we always have to refetch objects with List command without Delimiter provided to count in objects inside folders.
This change doesn't fix the main problem for recently deleted objects.

Change-Id: Ia64579745999301c285358869e283dff09399f41
  • Loading branch information
VitaliiShpital committed Oct 9, 2023
1 parent 1c0b23a commit d60e0f0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
11 changes: 7 additions & 4 deletions web/satellite/src/components/browser/FileBrowser.vue
Expand Up @@ -342,7 +342,7 @@ const currentPath = computed((): string => {
* Return locked files number.
*/
const lockedFilesCount = computed((): number => {
return objectsCount.value - (isPaginationEnabled.value ? fetchedObjectsCount.value : obStore.state.objectsCount);
return objectsCount.value - obStore.state.objectsCount;
});
/**
Expand Down Expand Up @@ -668,15 +668,18 @@ onBeforeMount(async () => {
await withLoading(async () => {
try {
if (isPaginationEnabled.value) {
await obStore.initList('');
await Promise.all([
obStore.initList(''),
obStore.getObjectCount(),
]);
} else {
await Promise.all([
list(''),
obStore.getObjectCount(),
]);
}
} catch (err) {
notify.error(err.message, AnalyticsErrorEventSource.FILE_BROWSER_LIST_CALL);
} catch (error) {
notify.error(error.message, AnalyticsErrorEventSource.FILE_BROWSER_LIST_CALL);
}
});
});
Expand Down
9 changes: 3 additions & 6 deletions web/satellite/src/components/objects/UploadFile.vue
Expand Up @@ -117,18 +117,15 @@ watch(passphrase, async () => {
});
try {
let promises: Promise<void>[] = [
const promises: Promise<void>[] = [
bucketsStore.getBuckets(bucketPage.value.currentPage, projectID),
obStore.getObjectCount(),
];
if (isPaginationEnabled.value) {
promises.push(obStore.initList(''));
} else {
promises = [
...promises,
obStore.list(''),
obStore.getObjectCount(),
];
promises.push(obStore.list(''));
}
await Promise.all(promises);
Expand Down
12 changes: 9 additions & 3 deletions web/satellite/src/store/modules/objectBrowserStore.ts
Expand Up @@ -411,11 +411,17 @@ export const useObjectBrowserStore = defineStore('objectBrowser', () => {
async function getObjectCount(): Promise<void> {
assertIsInitialized(state);

const responseV2 = await state.s3.send(new ListObjectsV2Command({
const paginator = paginateListObjectsV2({ client: state.s3, pageSize: MAX_KEY_COUNT }, {
Bucket: state.bucket,
}));
MaxKeys: MAX_KEY_COUNT,
});

let keyCount = 0;
for await (const response of paginator) {
keyCount += response.KeyCount ?? 0;
}

state.objectsCount = responseV2.KeyCount === undefined ? 0 : responseV2.KeyCount;
state.objectsCount = keyCount;
}

async function upload({ e }: { e: DragEvent | Event }): Promise<void> {
Expand Down

0 comments on commit d60e0f0

Please sign in to comment.