Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit 4fd30ad

Browse files
committed
fix: ensure storage base directory exists and improve error handling in StorageServiceImpl
1 parent ebd81bc commit 4fd30ad

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/java/com/example/springprojectsteganographytool/services/impl/StorageServiceImpl.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,16 @@ public StorageServiceImpl(@Value("${app.storage.base-path}") Path basePath) thro
3737
throw new IllegalArgumentException("app.storage.base-path must not be null");
3838
}
3939

40-
log.info("Using storage base path: {}", basePath.toAbsolutePath().normalize());
4140
this.basePath = basePath.toAbsolutePath().normalize();
41+
42+
// **KEY CHANGE: Ensure the base directory exists**
43+
try {
44+
Files.createDirectories(this.basePath);
45+
log.info("Using storage base path: {}", this.basePath);
46+
} catch (IOException e) {
47+
log.error("Failed to create storage base path: {}", this.basePath, e);
48+
throw new IllegalArgumentException("Cannot create storage directory: " + this.basePath, e);
49+
}
4250
}
4351

4452
/**

0 commit comments

Comments
 (0)