Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
* ****************************************************************************** */
package org.eclipse.openvsx.storage;

import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.List;

import jakarta.annotation.PostConstruct;

Comment on lines 10 to 19
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There’s no blank line between the package declaration and the first import. Other classes in this package keep a blank line after package ...; (e.g., AwsStorageService.java:11-13), and this can trip formatting/checkstyle rules.

Copilot uses AI. Check for mistakes.
import org.apache.commons.lang3.StringUtils;
import org.eclipse.openvsx.entities.FileResource;
import org.eclipse.openvsx.entities.Namespace;
Expand All @@ -22,14 +32,6 @@
import org.springframework.web.server.ServerErrorException;
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;

import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.List;

@Component
public class LocalStorageService implements IStorageService {

Expand All @@ -40,6 +42,27 @@ public class LocalStorageService implements IStorageService {
public boolean isEnabled() {
return !StringUtils.isEmpty(storageDirectory);
}

@PostConstruct
public void validateStorageDirectory() throws IOException {
if (!isEnabled()) {
return;
}

var storageDirectoryPath = Path.of(storageDirectory).toAbsolutePath();

if (!Files.exists(storageDirectoryPath)) {
Files.createDirectories(storageDirectoryPath);
}

if (!Files.isDirectory(storageDirectoryPath)) {
throw new IllegalStateException("Local storage directory '" + storageDirectory + "' is not a directory");
}

if (!Files.isWritable(storageDirectoryPath)) {
throw new IllegalStateException("Local storage directory '" + storageDirectory + "' is not writable");
}
}
Comment on lines 46 to 65
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces new startup behavior (fail-fast validation) but there are no focused tests exercising the writable vs non-writable cases for local storage. Given the existing test coverage for other storage services, it would be good to add tests that assert the app context fails to start (or the validator throws) when the directory is not writable, and succeeds when it is.

Copilot uses AI. Check for mistakes.

@Override
public void uploadFile(TempFile tempFile) {
Expand Down
Loading