Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/config/drive.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const drive = {
enabled: true,
progressBarDelay: 500,
prefetchDelay: 100,
unvisitableExtensions: new Set(
[
".7z", ".aac", ".apk", ".avi", ".bmp", ".bz2", ".css", ".csv", ".deb", ".dmg", ".doc",
Expand Down
10 changes: 6 additions & 4 deletions src/core/drive/prefetch_cache.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { LRUCache } from "../lru_cache"
import { toCacheKey } from "../url"

const PREFETCH_DELAY = 100
import { config } from "../config"

class PrefetchCache extends LRUCache {
#prefetchTimeout = null
#maxAges = {}

constructor(size = 1, prefetchDelay = PREFETCH_DELAY) {
constructor(size = 1) {
super(size, toCacheKey)
this.prefetchDelay = prefetchDelay
}

get prefetchDelay() {
return config.drive.prefetchDelay
}

putLater(url, request, ttl) {
Expand Down
13 changes: 13 additions & 0 deletions src/tests/unit/export_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ test("Session interface", () => {
assert.equal("off", config.forms.mode)
})

test("config.drive.prefetchDelay is configurable", () => {
const { config } = Turbo

assert.equal(100, config.drive.prefetchDelay)

config.drive.prefetchDelay = 200

assert.equal(200, config.drive.prefetchDelay)

// Reset to default
config.drive.prefetchDelay = 100
})

test("StreamActions interface", () => {
assert.equal(typeof StreamActions, "object")
})