Skip to content
This repository has been archived by the owner on Jun 10, 2021. It is now read-only.

Commit

Permalink
Workaround to import info of apps with 2 entries in the appstream file
Browse files Browse the repository at this point in the history
This workaround will enable parsing properly the appdata info for this apps
that have 2 entries in the appstream file (one with .desktop in the id
and another without)

org.musicbrainz.Picard
org.blender.Blender
com.lettier.movie-monad
org.zim_wiki.Zim
org.photoqt.PhotoQt
xyz.z3ntu.razergenie
org.gnome.Lollypop
im.srain.Srain
org.mozilla.Thunderbird
org.jamovi.jamovi
org.freedesktop.GstDebugViewer
com.github.gyunaev.spivak
org.gpodder.gpodder
org.gnome.Eolie

Fixes flathub/org.mozilla.Thunderbird#7
Fixes flathub/org.jamovi.jamovi#3
Fixes flathub/org.gnome.Eolie#6
  • Loading branch information
jgarciao committed Apr 20, 2018
1 parent 12ea562 commit 24bc353
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<dependency>
<groupId>org.freedesktop.appstream</groupId>
<artifactId>appstream-appdata</artifactId>
<version>0.4.0</version>
<version>0.4.1</version>
</dependency>

<dependency>
Expand Down
35 changes: 28 additions & 7 deletions src/main/java/org/flathub/api/service/UpdateServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.xml.bind.JAXBException;
import org.flathub.api.model.App;
Expand Down Expand Up @@ -154,6 +157,9 @@ private AppstreamUpdateInfo getAppStreamUpdateInfo() throws IOException {

private void updateRepoInfo(FlatpakRepo repo, AppstreamUpdateInfo appstreamInfo) {

Map<String, AppdataComponent> incompleteComponentsMap = new HashMap<>();
AppdataComponent previousIncompleteComponentWithSameFlatpakId;

List<AppdataComponent> componentList = null;

LOGGER.info("Updating repo info for " + repo.getName());
Expand All @@ -172,22 +178,37 @@ private void updateRepoInfo(FlatpakRepo repo, AppstreamUpdateInfo appstreamInfo)

try {

if (!this.validateAppdataInformation(component)) {

LOGGER.warn("Component " + component.getFlatpakId()
+ " won't be added/updated in the store because it has incomplete or invalid appdata");
if(component.getFlatpakId() != null && APPSTREAM_TYPE_DESKTOP.equalsIgnoreCase(component.getType())){

} else {
previousIncompleteComponentWithSameFlatpakId = incompleteComponentsMap.get(component.getFlatpakId());
if(previousIncompleteComponentWithSameFlatpakId != null) {
component.merge(previousIncompleteComponentWithSameFlatpakId);
incompleteComponentsMap.remove(component.getFlatpakId());
}

if (APPSTREAM_TYPE_DESKTOP.equalsIgnoreCase(component.getType())) {
if (this.validateAppdataInformation(component)){
updateAppInfo(repo, appstreamInfo, component);
}

else{
incompleteComponentsMap.put(component.getFlatpakId(), component);
LOGGER.debug("Adding " + component.getFlatpakId()
+ " to the incomplete components list because it has incomplete or invalid appdata");
}
}

} catch (Exception e) {
LOGGER.error("Error updating info for app " + component.getFlatpakId(), e);
}
}


Iterator it = incompleteComponentsMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pair = (Map.Entry)it.next();
LOGGER.warn(pair.getKey() + " has incomplete appdata and won't be added/updated in the webstore");
it.remove(); // avoids a ConcurrentModificationException
}

}

//Once imported delete the appdata folder
Expand Down

0 comments on commit 24bc353

Please sign in to comment.