Skip to content

Conversation

@osamahan999
Copy link
Collaborator

@osamahan999 osamahan999 commented Sep 15, 2023

Previous to this fix, if an item has no album id, the entire import fails.

java.lang.NullPointerException: element cannot be mapped to a null key         at java.base/java.util.Objects.requireNonNull(Objects.java:246)         at java.base/java.util.stream.Collectors.lambda$groupingBy$53(Collectors.java:1134)         at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)         at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)         at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)         at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)         at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)         at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)         at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)         at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)         at org.datatransferproject.datatransfer.google.common.gphotos.GPhotosUpload.uploadItemsViaBatching(GPhotosUpload.java:137)         at org.datatransferproject.datatransfer.google.photos.GooglePhotosImporter.importPhotos(GooglePhotosImporter.java:212)         at org.datatransferproject.datatransfer.google.photos.GooglePhotosImporter.importItem(GooglePhotosImporter.java:191)         at org.datatransferproject.datatransfer.google.photos.GooglePhotosImporter.importItem(GooglePhotosImporter.java:69)         at org.datatransferproject.transfer.CallableImporter.call(CallableImporter.java:68)         at org.datatransferproject.transfer.CallableImporter.call(CallableImporter.java:37)         at org.datatransferproject.types.transfer.retry.RetryingCallable.call(RetryingCallable.java:85) ... ...

.collect(Collectors.groupingBy(DownloadableFile::getFolderId));
// Null album-id items get sent here into the empty string key
itemsByAlbumId.put(
"",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Only thing left to consider is whether or not an empty string is a possible album id. In the case that it is, this code will overwrite those items.

Maybe to be safe I can change the upload loop to upload the items in albums and then I can separately loop through the album-less items and upload them, without having to add them to the map.

Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe instead of empty string, we could use some other identifier that wont be an album id? something like "$JOB_ID$_ALBUMLESS_ITEMS" ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done, made the album-less identifier be the job id appended to "_ALBUMLESS_ITEMS", and tested locally. Thanks Siham!

@osamahan999 osamahan999 marked this pull request as ready for review September 20, 2023 22:04
@seehamrun seehamrun merged commit fea83bc into dtinit:master Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants