Implement gzip in FSGitRepoStore

This commit is contained in:
Shane Kilkelly 2021-01-14 13:56:19 +00:00
parent 1c81fcf501
commit eba7cbe696

View file

@ -139,6 +139,15 @@ public class FSGitRepoStore implements RepoStore {
return Tar.bz2.zip(getDotGitForProject(projectName), sizePtr); return Tar.bz2.zip(getDotGitForProject(projectName), sizePtr);
} }
@Override
public InputStream gzipProject(
String projectName,
long[] sizePtr
) throws IOException {
Project.checkValidProjectName(projectName);
return Tar.gzip.zip(getDotGitForProject(projectName), sizePtr);
}
@Override @Override
public void gcProject(String projectName) throws IOException { public void gcProject(String projectName) throws IOException {
Project.checkValidProjectName(projectName); Project.checkValidProjectName(projectName);
@ -171,6 +180,25 @@ public class FSGitRepoStore implements RepoStore {
Tar.bz2.unzip(dataStream, getDirForProject(projectName)); Tar.bz2.unzip(dataStream, getDirForProject(projectName));
} }
@Override
public void ungzipProject(
String projectName,
InputStream dataStream
) throws IOException {
Preconditions.checkArgument(
Project.isValidProjectName(projectName),
"[%s] invalid project name: ",
projectName
);
Preconditions.checkState(
getDirForProject(projectName).mkdirs(),
"[%s] directories for " +
"evicted project already exist",
projectName
);
Tar.gzip.unzip(dataStream, getDirForProject(projectName));
}
private File getDirForProject(String projectName) { private File getDirForProject(String projectName) {
Project.checkValidProjectName(projectName); Project.checkValidProjectName(projectName);
return Paths.get( return Paths.get(