mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Add checkDB to upgrade the DB
This commit is contained in:
committed by
Michael Mazour
parent
52e5d2921f
commit
eb77d166e2
+1
-1
@@ -22,7 +22,7 @@ public class GitBridgeApp implements Runnable {
|
|||||||
|
|
||||||
public static final int EXIT_CODE_FAILED = 1;
|
public static final int EXIT_CODE_FAILED = 1;
|
||||||
private static final String USAGE_MESSAGE =
|
private static final String USAGE_MESSAGE =
|
||||||
"usage: writelatex-git-bridge config_file";
|
"usage: writelatex-git-bridge [config_file]";
|
||||||
|
|
||||||
private String configFilePath;
|
private String configFilePath;
|
||||||
Config config;
|
Config config;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import uk.ac.ic.wlgitbridge.snapshot.push.PushResult;
|
|||||||
import uk.ac.ic.wlgitbridge.snapshot.push.exception.*;
|
import uk.ac.ic.wlgitbridge.snapshot.push.exception.*;
|
||||||
import uk.ac.ic.wlgitbridge.util.Log;
|
import uk.ac.ic.wlgitbridge.util.Log;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -114,6 +115,33 @@ public class Bridge {
|
|||||||
swapJob.start();
|
swapJob.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkDB() {
|
||||||
|
Log.info("Checking DB");
|
||||||
|
File rootDir = repoStore.getRootDirectory();
|
||||||
|
for (File f : rootDir.listFiles()) {
|
||||||
|
if (f.getName().equals(".wlgb")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String projName = f.getName();
|
||||||
|
try (LockGuard __ = lock.lockGuard(projName)) {
|
||||||
|
File dotGit = new File(f, ".git");
|
||||||
|
if (!dotGit.exists()) {
|
||||||
|
Log.warn("Project: {} has no .git", projName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ProjectState state = dbStore.getProjectState(projName);
|
||||||
|
if (state != ProjectState.NOT_PRESENT) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Log.warn("Project: {} not in swap_store, adding", projName);
|
||||||
|
dbStore.setLastAccessedTime(
|
||||||
|
projName,
|
||||||
|
new Timestamp(dotGit.lastModified())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean projectExists(
|
public boolean projectExists(
|
||||||
Credential oauth2,
|
Credential oauth2,
|
||||||
String projectName
|
String projectName
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ public class GitBridgeServer {
|
|||||||
*/
|
*/
|
||||||
public void start() {
|
public void start() {
|
||||||
try {
|
try {
|
||||||
|
bridge.checkDB();
|
||||||
jettyServer.start();
|
jettyServer.start();
|
||||||
bridge.startSwapJob();
|
bridge.startSwapJob();
|
||||||
Log.info(Util.getServiceName() + "-Git Bridge server started");
|
Log.info(Util.getServiceName() + "-Git Bridge server started");
|
||||||
|
|||||||
Reference in New Issue
Block a user