Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

build(app-proxy): keep only brotli copies of assets, skip maps

Hampuseabfbd81a8ae
diff --git a/fluxer_app_proxy/scripts/precompress_assets.sh b/fluxer_app_proxy/scripts/precompress_assets.sh
index 736b139f5..b973d0c91 100755
--- a/fluxer_app_proxy/scripts/precompress_assets.sh
+++ b/fluxer_app_proxy/scripts/precompress_assets.sh
@@ -15,14 +15,6 @@ if [ "${PRECOMPRESS_WORKER:-}" = "1" ]; then
rm -f "$source_file.br"
fi
- if gzip -n "-$PRECOMPRESS_GZIP_LEVEL" -c "$source_file" >"$source_file.gz" 2>/dev/null; then
- if [ "$(wc -c <"$source_file.gz")" -ge "$source_size" ]; then
- rm -f "$source_file.gz"
- fi
- else
- rm -f "$source_file.gz"
- fi
-
exit 0
fi
@@ -35,22 +27,19 @@ esac
PRECOMPRESS_WORKER=1
PRECOMPRESS_BROTLI_QUALITY="${PRECOMPRESS_BROTLI_QUALITY:-11}"
-PRECOMPRESS_GZIP_LEVEL="${PRECOMPRESS_GZIP_LEVEL:-9}"
-export PRECOMPRESS_WORKER PRECOMPRESS_BROTLI_QUALITY PRECOMPRESS_GZIP_LEVEL
+export PRECOMPRESS_WORKER PRECOMPRESS_BROTLI_QUALITY
min_size="${PRECOMPRESS_MIN_SIZE_BYTES:-1024}"
jobs="${PRECOMPRESS_JOBS:-$(nproc 2>/dev/null || echo 1)}"
find "$root" -type f \
! -name '*.br' \
- ! -name '*.gz' \
-size +"${min_size}"c \
\( \
-name '*.css' -o \
-name '*.html' -o \
-name '*.js' -o \
-name '*.json' -o \
- -name '*.map' -o \
-name '*.mjs' -o \
-name '*.svg' -o \
-name '*.txt' -o \
diff --git a/fluxer_app_proxy/src/local_files.rs b/fluxer_app_proxy/src/local_files.rs
index 3e18a14e3..00529e996 100644
--- a/fluxer_app_proxy/src/local_files.rs
+++ b/fluxer_app_proxy/src/local_files.rs
@@ -166,21 +166,18 @@ impl LocalFileStore {
request_headers: &HeaderMap,
max_bytes: usize,
) -> Result<NegotiatedLocalFile, LocalFileReadError> {
- for &(encoding, extension) in PRECOMPRESSED_SIBLINGS {
- if !accepts_content_encoding(request_headers, encoding) {
- continue;
- }
- let sibling_path = format!("{relative_path}.{extension}");
+ if accepts_content_encoding(request_headers, "br") {
+ let sibling_path = format!("{relative_path}.br");
match self.resolve_checked(&sibling_path, max_bytes).await {
Ok(resolved) => {
- return self.with_stream_budget(resolved, Some(encoding), &sibling_path);
+ return self.with_stream_budget(resolved, Some("br"), &sibling_path);
}
Err(
LocalFileReadError::NotFound(_)
| LocalFileReadError::InvalidPath(_)
| LocalFileReadError::TooLarge { .. }
| LocalFileReadError::Io { .. },
- ) => continue,
+ ) => {}
Err(error) => return Err(error),
}
}