mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-29 12:01:32 +02:00
Merge pull request #12882 from overleaf/em-git-bridge-swap-job-config
Disable swap job when swap store is unsafe GitOrigin-RevId: 104b03e378e7802f9ba6ff96b5a626a2fa7960fb
This commit is contained in:
@@ -4,6 +4,7 @@ import uk.ac.ic.wlgitbridge.bridge.db.DBStore;
|
||||
import uk.ac.ic.wlgitbridge.bridge.lock.ProjectLock;
|
||||
import uk.ac.ic.wlgitbridge.bridge.repo.RepoStore;
|
||||
import uk.ac.ic.wlgitbridge.bridge.swap.store.SwapStore;
|
||||
import uk.ac.ic.wlgitbridge.util.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
@@ -60,16 +61,20 @@ public interface SwapJob {
|
||||
DBStore dbStore,
|
||||
SwapStore swapStore
|
||||
) {
|
||||
if (cfg.isPresent()) {
|
||||
return new SwapJobImpl(
|
||||
cfg.get(),
|
||||
lock,
|
||||
repoStore,
|
||||
dbStore,
|
||||
swapStore
|
||||
);
|
||||
if (!cfg.isPresent()) {
|
||||
return new NoopSwapJob();
|
||||
}
|
||||
return new NoopSwapJob();
|
||||
if (!swapStore.isSafe()) {
|
||||
Log.warn("Swap store '{}' is not safe; disabling swap job", swapStore.getClass().getSimpleName());
|
||||
return new NoopSwapJob();
|
||||
}
|
||||
return new SwapJobImpl(
|
||||
cfg.get(),
|
||||
lock,
|
||||
repoStore,
|
||||
dbStore,
|
||||
swapStore
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,4 +51,8 @@ public class InMemorySwapStore implements SwapStore {
|
||||
store.remove(projectName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSafe() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,4 +25,8 @@ public class NoopSwapStore implements SwapStore {
|
||||
@Override
|
||||
public void remove(String projectName) {}
|
||||
|
||||
@Override
|
||||
public boolean isSafe() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,4 +83,8 @@ public class S3SwapStore implements SwapStore {
|
||||
s3.deleteObject(del);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSafe() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,4 +41,11 @@ public interface SwapStore {
|
||||
|
||||
void remove(String projectName);
|
||||
|
||||
/**
|
||||
* Returns true if the swap store safely persists swapped projects.
|
||||
*
|
||||
* Fake swap stores should return false.
|
||||
*/
|
||||
boolean isSafe();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user