Skip to content

Commit e4ef50a

Browse files
authored
Merge pull request #229 from autonomys/improve-encoding-management
Improve encoding management
2 parents c53917d + 8e3373c commit e4ef50a

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

backend/__tests__/e2e/users/credits.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { SubscriptionsUseCases } from '../../../src/useCases/index.js'
1212
describe('CreditsUseCases', () => {
1313
let mockUser: UserWithOrganization
1414

15-
beforeAll(async () => {
15+
beforeEach(async () => {
1616
mockRabbitPublish()
1717
await getDatabase()
1818
await dbMigration.up()
@@ -21,7 +21,7 @@ describe('CreditsUseCases', () => {
2121
if (!result) throw new PreconditionError('Failed to setup test user')
2222
})
2323

24-
afterAll(async () => {
24+
afterEach(async () => {
2525
unmockMethods()
2626
await closeDatabase()
2727
await dbMigration.down()

backend/src/repositories/objects/interactions.ts

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ const getInteractionsBySubscriptionIdAndTypeInTimeRange = async (
5151
[subscriptionId, type, start.toISOString(), end.toISOString()],
5252
)
5353

54+
console.log(interactions.rows)
55+
5456
return mapRows(interactions.rows)
5557
}
5658

backend/src/services/download/express.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ export const handleDownloadResponseHeaders = (
99
const safeName = encodeURIComponent(metadata.name || 'download')
1010
const isExpectedDocument = req.headers['sec-fetch-site'] === 'none'
1111

12+
const shouldHandleEncoding = req.query.ignoreEncoding
13+
? req.query.ignoreEncoding !== 'true'
14+
: isExpectedDocument
15+
1216
if (metadata.type === 'file') {
1317
res.set('Content-Type', metadata.mimeType || 'application/octet-stream')
1418
res.set(
@@ -17,7 +21,7 @@ export const handleDownloadResponseHeaders = (
1721
)
1822
const compressedButNoEncrypted =
1923
metadata.uploadOptions?.compression && !metadata.uploadOptions?.encryption
20-
if (compressedButNoEncrypted && isExpectedDocument) {
24+
if (compressedButNoEncrypted && shouldHandleEncoding) {
2125
res.set('Content-Encoding', 'deflate')
2226
}
2327
res.set('Content-Length', metadata.totalSize.toString())

0 commit comments

Comments
 (0)