plugin/download-counter: ignore flag
Massimo Melina committed
Jun 26, 2023 at 23:27 UTC
cab0ec3e122a4a22a56bdb5bfca0110046e9787d
1 file changed
+3
-1
plugins/download-counter/plugin.js
+3
-1
@@ -1,3 +1,5 @@
1
+// other plugins can use ctx.state.download_counter_ignore to mark downloads that shouldn't be counted
2
+
3
exports.description = "Counts downloads for each file, and displays the total in the list or file menu"
4
exports.version = 4.1 // fix: different cases and encodings with urls weren't properly counted
5
exports.apiRequired = 8
@@ -43,7 +45,7 @@ exports.init = async api => {
45
unload: () => save.flush(), // we may have pending savings
46
middleware: (ctx) =>
47
() => { // execute after other middlewares are done
46
- if (ctx.status >= 300 || !ctx.vfsNode) return
48
+ if (ctx.status >= 300 || !ctx.vfsNode || ctx.state.download_counter_ignore) return
49
const k = uri2key(ctx.path)
50
counters[k] = counters[k] + 1 || 1
51
save()