Skip to content

Commit

Permalink
#89 add temp directory per site
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorsten Marx committed Nov 21, 2023
1 parent 36d025b commit 6374e12
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ target/
.vscode/
cms-server/hosts/marx-software
cms-server/hosts/demo/modules_data/search-module/index
cms-server/hosts/demo/temp
cms-server/hosts/theme-demo/modules_data/search-module/index
cms-server/modules/flexmark-module
cms-server/modules/markedjs-module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
public class MediaManager {

private final Path assetBase;
private final Path tempFolder;
private final Theme theme;
private final SiteProperties siteProperties;

Expand All @@ -64,7 +65,10 @@ public MediaFormat getMediaFormat (String format) {

private Path getTempDirectory() throws IOException {
if (tempDirectory == null) {
tempDirectory = Files.createTempDirectory("cms-media-temp");
tempDirectory = tempFolder.resolve("media");
if (!Files.exists(tempDirectory)) {
Files.createDirectories(tempDirectory);
}
}
return tempDirectory;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
@Slf4j
public class VHost {

private FileSystem fileSystem;
protected FileSystem fileSystem;

protected ContentRenderer contentRenderer;
protected ContentResolver contentResolver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public Handler httpHandler() {
pathMappingsHandler.addMapping(PathSpec.from("/assets/*"), assetsHandler);
pathMappingsHandler.addMapping(PathSpec.from("/favicon.ico"), faviconHandler);

JettyMediaHandler mediaHandler = new JettyMediaHandler(new MediaManager(assetBase, getTheme(), siteProperties));
JettyMediaHandler mediaHandler = new JettyMediaHandler(new MediaManager(assetBase, fileSystem.resolve("temp"), getTheme(), siteProperties));
pathMappingsHandler.addMapping(PathSpec.from("/media/*"), mediaHandler);

ContextHandler defaultContextHandler = new ContextHandler(pathMappingsHandler, "/");
Expand Down Expand Up @@ -121,7 +121,7 @@ private ContextHandler themeContextHandler () {
PathMappingsHandler pathMappingsHandler = new PathMappingsHandler();
pathMappingsHandler.addMapping(PathSpec.from("/assets/*"), assetsHandler);

JettyMediaHandler mediaHandler = new JettyMediaHandler(new MediaManager(getTheme().assetsPath(), getTheme(), siteProperties));
JettyMediaHandler mediaHandler = new JettyMediaHandler(new MediaManager(getTheme().assetsPath(), fileSystem.resolve("temp"), getTheme(), siteProperties));
pathMappingsHandler.addMapping(PathSpec.from("/media/*"), mediaHandler);

return new ContextHandler(pathMappingsHandler, "/themes/" + getTheme().getName());
Expand Down

0 comments on commit 6374e12

Please sign in to comment.