Skip to content

Commit

Permalink
do not give up early when trying to push
Browse files Browse the repository at this point in the history
  • Loading branch information
Orbiter committed Oct 30, 2018
1 parent dea2698 commit 34b6981
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/ai/susi/DAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,9 @@ public static void close() {
passwordreset.close();
accounting.close();

// close pull thread
SkillTransactions.close();

log("closed DAO");
}

Expand Down
22 changes: 13 additions & 9 deletions src/ai/susi/SkillTransactions.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@

public class SkillTransactions {

public static Boolean pullStatus = true;
public static String conflictsPlaceholder = "%CONFLICTS%";
private static Boolean pullStatus = true;
public static String conflictsPlaceholder = "%CONFLICTS%";
private static ConcurrentLinkedDeque<CommitAction> pushQueue = new ConcurrentLinkedDeque<>();
private static Thread pullThread;

/**
* initialize the DAO
Expand All @@ -55,7 +56,7 @@ public class SkillTransactions {
public static void init(long pull_delay) throws Exception{

DAO.log("Starting Skill Data pull thread");
Thread pullThread = new Thread() {
pullThread = new Thread() {
@Override
public void run() {
while (pullStatus) {
Expand All @@ -64,22 +65,26 @@ public void run() {
} catch (InterruptedException e) {
break;
}
while (pushQueue.size() > 0) {
CommitAction ca = pushQueue.removeFirst();
ca.process();
}
try {
pull(getPublicGit());
} catch (Exception e) {
pullStatus = false;
DAO.severe("SKILL PULL THREAD", e);
}
while (pushQueue.size() > 0) {
CommitAction ca = pushQueue.removeFirst();
ca.process();
}
}
}
};
pullThread.start();
}

public static void close() {
pullStatus = false;
pullThread.interrupt();
}

public static Repository getPublicRepository() throws IOException {
Repository repo;
File repoFile = DAO.susi_skill_repo;
Expand Down Expand Up @@ -143,7 +148,6 @@ public static void pull(Git git) throws IOException {
MergeResult mergeResult = pullResult.getMergeResult();

if (mergeResult!=null && mergeResult.getConflicts()!=null) {
pullStatus =false;
// we have conflicts send email to admin
try {
EmailHandler.sendEmail(DAO.getConfig("skill_repo.admin_email",""), "SUSI Skill Data Conflicts", getConflictsMailContent(mergeResult));
Expand Down

0 comments on commit 34b6981

Please sign in to comment.