|
28 | 28 | import java.net.http.HttpResponse; |
29 | 29 | import java.net.http.HttpTimeoutException; |
30 | 30 | import java.nio.charset.StandardCharsets; |
| 31 | +import java.nio.file.AccessDeniedException; |
31 | 32 | import java.nio.file.Files; |
32 | 33 | import java.nio.file.Path; |
33 | 34 | import java.time.Duration; |
@@ -230,26 +231,28 @@ public static void findMods(Executor executor, IDiscoveryPipeline pipeline) thro |
230 | 231 | } |
231 | 232 | } |
232 | 233 |
|
233 | | - var repositoryEnv = Optional.ofNullable(System.getenv("PACK_SYNC_REPO_DIRECTORY")).orElse(""); |
234 | | - var repository = repositoryEnv.isEmpty() ? Path.of(System.getProperty("user.home")).resolve(".latvian.dev").resolve("pack-sync") : Path.of(repositoryEnv); |
| 234 | + var localRepository = localPackSyncDirectory.resolve("repository"); |
235 | 235 |
|
236 | | - if (Files.notExists(repository) || !Files.isDirectory(repository)) { |
| 236 | + if (Files.notExists(localRepository)) { |
237 | 237 | try { |
238 | | - Files.createDirectories(repository); |
| 238 | + Files.createDirectories(localRepository); |
239 | 239 | } catch (Exception ex) { |
240 | | - pipeline.addIssue(ModLoadingIssue.error("Failed to create Pack Sync repository directory!").withCause(ex).withAffectedPath(repository)); |
| 240 | + pipeline.addIssue(ModLoadingIssue.error("Failed to create Pack Sync local repository directory!").withCause(ex).withAffectedPath(localRepository)); |
241 | 241 | return; |
242 | 242 | } |
243 | 243 | } |
244 | 244 |
|
245 | | - var localRepository = localPackSyncDirectory.resolve("repository"); |
| 245 | + var repositoryEnv = Optional.ofNullable(System.getenv("PACK_SYNC_REPO_DIRECTORY")).orElse(""); |
| 246 | + var repository = repositoryEnv.isEmpty() ? Path.of(System.getProperty("user.home")).resolve(".latvian.dev").resolve("pack-sync") : Path.of(repositoryEnv); |
246 | 247 |
|
247 | | - if (Files.notExists(localRepository)) { |
| 248 | + if (Files.notExists(repository) || !Files.isDirectory(repository)) { |
248 | 249 | try { |
249 | | - Files.createDirectories(localRepository); |
| 250 | + Files.createDirectories(repository); |
| 251 | + } catch (AccessDeniedException ex) { |
| 252 | + repository = localRepository; |
| 253 | + LOGGER.error("Failed to create Pack Sync repository directory! Switching to local repository directory"); |
250 | 254 | } catch (Exception ex) { |
251 | | - pipeline.addIssue(ModLoadingIssue.error("Failed to create Pack Sync local repository directory!").withCause(ex).withAffectedPath(localRepository)); |
252 | | - return; |
| 255 | + pipeline.addIssue(ModLoadingIssue.error("Failed to create Pack Sync repository directory!").withCause(ex).withAffectedPath(repository)); |
253 | 256 | } |
254 | 257 | } |
255 | 258 |
|
|
0 commit comments