-
Notifications
You must be signed in to change notification settings - Fork 490
Add items with null album-ids into the item-map with an empty string key #1267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…m photos and videos
…roject into album-id-fix
| .collect(Collectors.groupingBy(DownloadableFile::getFolderId)); | ||
| // Null album-id items get sent here into the empty string key | ||
| itemsByAlbumId.put( | ||
| "", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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" ?
There was a problem hiding this comment.
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!
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) ... ...