diff --git a/.gitignore b/.gitignore
index 35b23c5..0cb9f41 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,7 +33,8 @@ pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
release.properties
+.factorypath
application.yaml
build.sh
-*log
\ No newline at end of file
+*log
diff --git a/pom.xml b/pom.xml
index 4901a42..548e444 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,10 +12,10 @@
11
UTF-8
UTF-8
- 2.5.1.Final
+ 2.5.4.Final
quarkus-bom
io.quarkus
- 2.5.1.Final
+ 2.5.4.Final
2.22.1
diff --git a/src/main/java/sh/rhiobet/lalafin/api/advent/AdventAccessService.java b/src/main/java/sh/rhiobet/lalafin/api/advent/AdventAccessService.java
index c3e63a9..4486015 100644
--- a/src/main/java/sh/rhiobet/lalafin/api/advent/AdventAccessService.java
+++ b/src/main/java/sh/rhiobet/lalafin/api/advent/AdventAccessService.java
@@ -42,8 +42,12 @@ public class AdventAccessService {
try {
int day = Integer.parseInt(dayString);
LocalDateTime now = LocalDateTime.now();
- if (now.getYear() >= event.year() && now.getMonthValue() >= event.month()
- && now.getDayOfMonth() >= day) {
+ if ((now.getYear() > event.year())
+ || (now.getYear() == event.year()
+ && now.getMonthValue() > event.month())
+ || (now.getYear() == event.year()
+ && now.getMonthValue() == event.month()
+ && now.getDayOfMonth() >= day)) {
return true;
} else {
return false;
diff --git a/src/main/java/sh/rhiobet/lalafin/file/FileInfoService.java b/src/main/java/sh/rhiobet/lalafin/file/FileInfoService.java
index bf5ad0b..43a83b2 100644
--- a/src/main/java/sh/rhiobet/lalafin/file/FileInfoService.java
+++ b/src/main/java/sh/rhiobet/lalafin/file/FileInfoService.java
@@ -85,10 +85,8 @@ public class FileInfoService {
Path requestedThumbPath =
path.getParent().resolve(".thumbnails").resolve(requestedFilename + ".jpg");
if (Files.exists(requestedThumbPath)) {
- requestedThumbUrl =
- rootFolderPath.relativize(requestedThumbPath).toUri().getRawPath();
- // For some reason, url starts with '/work'
- requestedThumbUrl = requestedThumbUrl.substring(5);
+ requestedThumbUrl = Paths.get("/").resolve(
+ rootFolderPath.relativize(requestedThumbPath)).toUri().getRawPath();
}
} catch (Exception ignored) {
}
@@ -97,7 +95,7 @@ public class FileInfoService {
requestedFilename = "/";
}
FolderInfo folderInfo = new FolderInfo(requestedFilename, requestedThumbUrl,
- "/file" + requestedUri, "/view" + requestedUri + "/1");
+ "/file" + requestedUri + "/", "/view" + requestedUri + "/1");
try {
Files.list(path).forEach(p -> {
String fileName = p.getFileName().toString();
@@ -122,7 +120,7 @@ public class FileInfoService {
FileInfoBase contentInfo;
if (Files.isDirectory(p)) {
contentInfo = new FolderInfo(fileName,
- "/file" + requestedUri + "/" + fileUri);
+ "/file" + requestedUri + "/" + fileUri + "/");
} else {
contentInfo =
new FileInfo(fileName, "/file" + requestedUri + "/" + fileUri);
diff --git a/src/main/java/sh/rhiobet/lalafin/file/FileServeService.java b/src/main/java/sh/rhiobet/lalafin/file/FileServeService.java
index b644e3f..520777b 100644
--- a/src/main/java/sh/rhiobet/lalafin/file/FileServeService.java
+++ b/src/main/java/sh/rhiobet/lalafin/file/FileServeService.java
@@ -12,8 +12,8 @@ import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
-import io.quarkus.qute.Template;
import io.quarkus.qute.Location;
+import io.quarkus.qute.Template;
import sh.rhiobet.lalafin.api.configuration.FileApiConfiguration;
import sh.rhiobet.lalafin.api.model.FileInfo;
import sh.rhiobet.lalafin.api.model.FileInfoBase;
@@ -44,24 +44,24 @@ public class FileServeService {
Path path = Paths.get(fileApiConfiguration.directory(),
URLDecoder.decode(fileInfo.directUrl, StandardCharsets.UTF_8));
FileChannel channel = FileChannel.open(path);
- InputStream is = Channels.newInputStream(channel);
+ ResponseBuilder response;
long fileSize = channel.size();
- long rangeStart = 0;
if (range != null) {
- rangeStart = Long.parseLong(range.substring(6, range.length() - 1));
+ long rangeStart = Long.parseLong(range.substring(6, range.length() - 1));
+ InputStream is = Channels.newInputStream(channel);
is.skip(rangeStart);
- }
- ResponseBuilder response = Response.ok(path.toFile());
- response.entity(is);
- response.header("Accept-Ranges", "bytes");
- response.header("Content-Length", fileSize);
- response.header("Content-Disposition",
- "inline; filename=\"" + fileInfo.filename + "\"");
- if (rangeStart > 0) {
+ response = Response.ok(path.toFile());
+ response.entity(is);
+ response.header("Content-Length", Long.toString(fileSize - rangeStart));
response.status(Response.Status.PARTIAL_CONTENT);
response.header("Content-Range",
- "bytes " + rangeStart + "-" + fileSize + "/" + fileSize);
+ "bytes " + rangeStart + "-" + (fileSize - 1) + "/" + fileSize);
+ } else {
+ response = Response.ok(path.toFile());
+ response.header("Content-Length", Long.toString(fileSize));
}
+ response.header("Content-Disposition",
+ "inline; filename=\"" + fileInfo.filename + "\"");
response.header("Content-Type", FileHelper.getMimeType(fileInfo.filename));
if (path.toString().contains("/.thumbnails/")) {
response.header("Cache-Control", "max-age=604800");
diff --git a/src/main/resources/templates/directory-index.html b/src/main/resources/templates/directory-index.html
index 51246e8..3124167 100644
--- a/src/main/resources/templates/directory-index.html
+++ b/src/main/resources/templates/directory-index.html
@@ -9,9 +9,9 @@
{info.filename}
{#if !info.filename is '/'}
- back
+ back
- viewer
+ viewer
{/if}
diff --git a/src/main/resources/templates/view-index.html b/src/main/resources/templates/view-index.html
index a7a9763..16bdb7f 100644
--- a/src/main/resources/templates/view-index.html
+++ b/src/main/resources/templates/view-index.html
@@ -16,9 +16,9 @@
{#if currpage < totpage}{/if}
- {#if image != null}
+ {#if image??}
- {#else if video != null}
+ {#else if video??}
{/if}
{#if currpage < totpage}{/if}