mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-17 16:20:03 +00:00
Improved logging for client-aborted downloads
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package de.grimsi.gameyfin.exceptions;
|
||||
|
||||
public class DownloadAbortedException extends RuntimeException {
|
||||
public DownloadAbortedException() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -2,18 +2,19 @@ package de.grimsi.gameyfin.service;
|
||||
|
||||
import de.grimsi.gameyfin.entities.Company;
|
||||
import de.grimsi.gameyfin.entities.DetectedGame;
|
||||
import de.grimsi.gameyfin.exceptions.DownloadAbortedException;
|
||||
import de.grimsi.gameyfin.igdb.IgdbApiProperties;
|
||||
import de.grimsi.gameyfin.repositories.DetectedGameRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.catalina.connector.ClientAbortException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||
import org.springframework.data.repository.core.RepositoryCreationException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
@@ -88,7 +89,15 @@ public class DownloadService {
|
||||
Path path = Path.of(game.getPath());
|
||||
|
||||
if (path.toFile().isDirectory()) {
|
||||
|
||||
try {
|
||||
downloadFilesAsZip(path, outputStream);
|
||||
} catch(DownloadAbortedException e) {
|
||||
stopWatch.stop();
|
||||
log.info("Download of game {} was aborted by client after {} seconds", game.getTitle(), (int) stopWatch.getTotalTimeSeconds());
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
downloadFile(path, outputStream);
|
||||
}
|
||||
@@ -99,7 +108,6 @@ public class DownloadService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void downloadGameCoversFromIgdb() {
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
|
||||
@@ -180,6 +188,9 @@ public class DownloadService {
|
||||
});
|
||||
|
||||
zos.close();
|
||||
} catch (ClientAbortException e) {
|
||||
// Aborted downloads will be handled gracefully
|
||||
throw new DownloadAbortedException();
|
||||
} catch (IOException e) {
|
||||
log.error("Error while zipping files:", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user