Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- (GH #788) Fix for objects of a copied folder rendering their tags correctly
- (GH #781) Render full details of Folders you have shared and Folders shared with you
- Show Folder status including Shared status, source project and date of sharing
- Show tags for Folders and Objects inside them
Expand Down Expand Up @@ -50,6 +49,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- (GH #827) Fixed for updating folder's items count and size when deleting objects inside it
- (GH #788) Fixed for objects of a copied folder rendering their tags correctly
- (GH #741) Fixed incorrect API token list logic causing an incorrect 404
- (GH #780) Fixed tables' Display Options rendering the menu options correctly when data changed
- (GH #502) Items being removed from IndexedDB on network errors.
Expand Down
3 changes: 2 additions & 1 deletion swift_browser_ui_frontend/src/common/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ export async function swiftDeleteObjects(
let ret = await DELETE(
fetchURL, JSON.stringify(objects),
);
if (ret.status != 204) {

if (ret.status != 200) {
throw new Error("Object / objects deletion not successful.");
}
}
Expand Down
64 changes: 41 additions & 23 deletions swift_browser_ui_frontend/src/common/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
getMetadataForSharedContainer,
getTagsForObjects,
makeGetObjectsMetaURL,
filterSegments,
tokenize,
} from "./conv";

Expand Down Expand Up @@ -248,7 +247,6 @@ const store = new Vuex.Store({
commit("loading", true);
}
let containers;
//let sharedContainers;
let marker = "";
let newContainers = [];
do {
Expand All @@ -262,7 +260,6 @@ const store = new Vuex.Store({
cont.tokens = tokenize(cont.name);
cont.projectID = projectID;
});
await state.db.containers.bulkPut(containers).catch(() => {});
newContainers = newContainers.concat(containers);
marker = containers[containers.length - 1].name;
}
Expand Down Expand Up @@ -308,34 +305,47 @@ const store = new Vuex.Store({
.where({ projectID })
.toArray();

for (let i = 0; i < containersFromDB.length; i++) {
const container = containersFromDB[i];
const oldContainer = existingContainers.find(
for (let i = 0; i < newContainers.length; i++) {
const container = newContainers[i];
const oldContainer = containersFromDB.find(
cont => cont.name === container.name,
);

let key;
let updateObjects = true;
const dbObjects = await state.db.objects
.where({ containerID: container.id })
.count();
let dbObjects = 0;

if (
oldContainer &&
container.count === oldContainer.count &&
container.bytes === oldContainer.bytes &&
!(dbObjects === 0)
) {
updateObjects = false;
if (oldContainer !== undefined) {
key = oldContainer.id;
dbObjects = await state.db.objects
.where({ containerID: oldContainer.id })
.count();
}
if (container.count === 0) {
updateObjects = false;
await state.db.objects.where({ containerID: container.id }).delete();
if (oldContainer !== undefined) {
if (
container.count === oldContainer.count &&
container.bytes === oldContainer.bytes &&
!(dbObjects === 0)
) {
updateObjects = false;
}
if (container.count === 0) {
updateObjects = false;
await state.db.objects
.where({ containerID: oldContainer.id })
.delete();
}
await state.db.containers.update(oldContainer.id, container);
} else {
key = await state.db.containers.put(container);
}

if (updateObjects && !container.owner) {
dispatch("updateObjects", {
projectID: projectID,
container: container,
container: {
id: key,
...container,
},
signal: signal,
});
}
Expand Down Expand Up @@ -375,7 +385,6 @@ const store = new Vuex.Store({
obj.containerID = container.id;
obj.tokens = isSegmentsContainer ? [] : tokenize(obj.name);
});
await state.db.objects.bulkPut(objects).catch(() => {});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nice to get rid of this :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

newObjects = newObjects.concat(objects);
marker = objects[objects.length - 1].name;
}
Expand All @@ -390,6 +399,16 @@ const store = new Vuex.Store({
if (toDelete.length) {
await state.db.objects.bulkDelete(toDelete);
}

newObjects.map(newObj => {
let oldObj = existingObjects.find(obj => obj.name === newObj.name);

if (oldObj) {
state.db.objects.update(oldObj.id, newObj);
} else {
state.db.objects.put(newObj);
}
});
if (!isSegmentsContainer) {
dispatch("updateObjectTags", {
projectID,
Expand Down Expand Up @@ -487,7 +506,6 @@ const store = new Vuex.Store({
}
} while (objects.length > 0);
commit("loading", false);
sharedObjects = filterSegments(sharedObjects);
commit("updateObjects", sharedObjects);
dispatch("updateObjectTags", {
projectID: project,
Expand Down