mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-02-22 06:26:56 +01:00
Use repository specific work dirs (#1510)
With this change, work dirs are created in the directory of the repository and no longer in the global scm work dir directory. This is relevant due to two facts: 1. Repositories may contain confidential data and therefore reside in special directories (that may be mounted on special drives). It may be considered a breach when these directories are cloned or otherwise copied to global temporary drives. 2. Big repositories may overload global temp spaces. It may be easier to create special drives with more space for such big repositories.
This commit is contained in:
@@ -87,7 +87,8 @@ class FullScmRepositoryExporterTest {
|
||||
void shouldExportEverythingAsTarArchive(@TempDir Path temp) throws IOException {
|
||||
BundleCommandBuilder bundleCommandBuilder = mock(BundleCommandBuilder.class);
|
||||
when(repositoryService.getBundleCommand()).thenReturn(bundleCommandBuilder);
|
||||
when(workdirProvider.createNewWorkdir()).thenAnswer(invocation -> createWorkDir(temp));
|
||||
when(repositoryService.getRepository()).thenReturn(REPOSITORY);
|
||||
when(workdirProvider.createNewWorkdir(anyString())).thenAnswer(invocation -> createWorkDir(temp, invocation.getArgument(0, String.class)));
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
exporter.export(REPOSITORY, baos);
|
||||
|
||||
@@ -98,8 +99,8 @@ class FullScmRepositoryExporterTest {
|
||||
workDirsCreated.forEach(wd -> assertThat(wd).doesNotExist());
|
||||
}
|
||||
|
||||
private File createWorkDir(Path temp) throws IOException {
|
||||
Path newWorkDir = temp.resolve("workDir-" + workDirsCreated.size());
|
||||
private File createWorkDir(Path temp, String repositoryId) throws IOException {
|
||||
Path newWorkDir = temp.resolve("workDir-" + repositoryId);
|
||||
workDirsCreated.add(newWorkDir);
|
||||
Files.createDirectories(newWorkDir);
|
||||
return newWorkDir.toFile();
|
||||
|
||||
Reference in New Issue
Block a user