hfs 0.56.0-beta5 → 0.56.0-beta6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hfs",
3
- "version": "0.56.0-beta5",
3
+ "version": "0.56.0-beta6",
4
4
  "description": "HTTP File Server",
5
5
  "keywords": ["file server", "http server"],
6
6
  "homepage": "https://rejetto.com/hfs",
@@ -1,7 +1,7 @@
1
1
  // other plugins can use ctx.state.download_counter_ignore to mark downloads that shouldn't be counted
2
2
 
3
3
  exports.description = "Counts downloads for each file, and displays the total in the list or file menu"
4
- exports.version = 6.2 // reintroduced conversion of legacy data
4
+ exports.version = 6.3 // fixed slow conversion of big legacy files
5
5
  exports.apiRequired = 8.89 // openDb
6
6
 
7
7
  exports.config = {
@@ -20,11 +20,14 @@ exports.init = async api => {
20
20
  try { // load legacy file
21
21
  const countersFile = 'counters.yaml'
22
22
  const yaml = api.require('yaml')
23
- const { readFile, rename } = api.require('fs/promises')
24
- const data = await readFile(countersFile, 'utf8')
25
- for (const [k,v] of Object.entries(yaml.parse(data)))
26
- db.put(uri2key(k), v)
27
- rename(countersFile, countersFile + ' - old format, now converted, you can delete')
23
+ const input = api.require('fs').createReadStream(countersFile)
24
+ const readline = api.require('readline').createInterface({ input })
25
+ for await (const line of readline) {
26
+ const parsed = yaml.parse(line) // parsing a 3.7MB file as a whole takes 25x in my tests
27
+ for (const [k,v] of Object.entries(parsed))
28
+ db.put(uri2key(k), v)
29
+ }
30
+ api.require('fs').promises.rename(countersFile, countersFile + ' - old format, now converted, you can delete')
28
31
  api.log("data converted")
29
32
  }
30
33
  catch(err) {
package/src/const.js CHANGED
@@ -54,7 +54,7 @@ exports.DEV = process.env.DEV || argv_1.argv.dev ? 'DEV' : '';
54
54
  exports.ORIGINAL_CWD = process.cwd();
55
55
  exports.HFS_STARTED = new Date();
56
56
  const PKG_PATH = (0, path_1.join)(__dirname, '..', 'package.json');
57
- exports.BUILD_TIMESTAMP = "2025-02-01T10:52:47.377Z";
57
+ exports.BUILD_TIMESTAMP = "2025-02-02T14:08:18.709Z";
58
58
  const pkg = JSON.parse(fs.readFileSync(PKG_PATH, 'utf8'));
59
59
  exports.VERSION = pkg.version;
60
60
  exports.RUNNING_BETA = exports.VERSION.includes('-');