src: fix context commit in scripts

I was wondering why the same bitstreams appeared to be getting de-
leted on every single run. It turns out that the only mode we were
committing the context in was in single item mode. If the argument
was a site, community, or collection we were updating the item but
not actually committing the changes!
This commit is contained in:
Alan Orth 2022-10-07 14:49:58 +03:00
parent 5ebf4930cf
commit 80a336f94d
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
2 changed files with 6 additions and 0 deletions

View File

@ -61,6 +61,7 @@ public class FixJpgJpgThumbnails {
switch (parent.getType()) { switch (parent.getType()) {
case Constants.SITE: case Constants.SITE:
process(context, itemService.findAll(context)); process(context, itemService.findAll(context));
context.commit();
break; break;
case Constants.COMMUNITY: case Constants.COMMUNITY:
List<Collection> collections = ((Community) parent).getCollections(); List<Collection> collections = ((Community) parent).getCollections();
@ -69,11 +70,13 @@ public class FixJpgJpgThumbnails {
context, context,
itemService.findAllByCollection(context, collection)); itemService.findAllByCollection(context, collection));
} }
context.commit();
break; break;
case Constants.COLLECTION: case Constants.COLLECTION:
process( process(
context, context,
itemService.findByCollection(context, (Collection) parent)); itemService.findByCollection(context, (Collection) parent));
context.commit();
break; break;
case Constants.ITEM: case Constants.ITEM:
processItem(context, (Item) parent); processItem(context, (Item) parent);

View File

@ -78,6 +78,7 @@ public class FixLowQualityThumbnails {
switch (parent.getType()) { switch (parent.getType()) {
case Constants.SITE: case Constants.SITE:
process(context, itemService.findAll(context)); process(context, itemService.findAll(context));
context.commit();
break; break;
case Constants.COMMUNITY: case Constants.COMMUNITY:
List<Collection> collections = ((Community) parent).getCollections(); List<Collection> collections = ((Community) parent).getCollections();
@ -86,11 +87,13 @@ public class FixLowQualityThumbnails {
context, context,
itemService.findAllByCollection(context, collection)); itemService.findAllByCollection(context, collection));
} }
context.commit();
break; break;
case Constants.COLLECTION: case Constants.COLLECTION:
process( process(
context, context,
itemService.findByCollection(context, (Collection) parent)); itemService.findByCollection(context, (Collection) parent));
context.commit();
break; break;
case Constants.ITEM: case Constants.ITEM:
processItem(context, (Item) parent); processItem(context, (Item) parent);