Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
disable etag encode in filesystem storage service
Browse files Browse the repository at this point in the history
  • Loading branch information
auguwu committed Dec 17, 2022
1 parent 67f6179 commit 9ef92ae
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ package org.noelware.remi.gradle
import org.gradle.api.JavaVersion
import dev.floofy.utils.gradle.*

val VERSION = Version(0, 5, 2, 0, ReleaseType.Beta)
val VERSION = Version(0, 5, 3, 0, ReleaseType.Beta)
val JAVA_VERSION = JavaVersion.VERSION_17
17 changes: 9 additions & 8 deletions core/src/main/java/org/noelware/remi/core/Blob.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ public class Blob {
* @param size The size of this blob.
*/
public Blob(
Instant lastModifiedAt,
Instant createdAt,
String contentType,
InputStream stream,
String etag,
String name,
String providerName,
String path,
@Nullable Instant lastModifiedAt,
@Nullable Instant createdAt,
@Nullable String contentType,
@Nullable InputStream stream,
@Nullable String etag,
@NotNull String name,
@NotNull String providerName,
@NotNull String path,
long size) {
this.lastModifiedAt = lastModifiedAt;
this.contentType = contentType;
Expand Down Expand Up @@ -131,6 +131,7 @@ public String path() {
/**
* @return etag for this blob
*/
@Nullable
public String etag() {
return etag;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,12 @@ public Blob blob(String path) throws IOException {
// Get the content type of the buffer
final String contentType = getContentTypeOf(data);

// Create the Etag for this file
final String etag =
"\"%s-%s\"".formatted(Long.toString(data.length, 16), sha1(data).substring(0, 27));
return new Blob(
attributes.lastModifiedTime().toInstant(),
attributes.creationTime().toInstant(),
contentType,
new ByteArrayInputStream(data),
etag,
null,
file.getName(),
"fs",
String.format("fs://%s", file),
Expand Down Expand Up @@ -187,18 +184,12 @@ public List<Blob> blobs(@Nullable ListBlobsRequest request) throws IOException {
throw new RuntimeException(e);
}

// Create the Etag for this file
final String etag = "\"%s-%s\""
.formatted(
Long.toString(data.length, 16),
sha1(data).substring(0, 27));

return new Blob(
attributes.lastModifiedTime().toInstant(),
attributes.creationTime().toInstant(),
contentType,
new ByteArrayInputStream(data),
etag,
null,
file.toFile().getName(),
"fs",
String.format("fs://%s", file),
Expand Down

0 comments on commit 9ef92ae

Please sign in to comment.