3v324v23 commited on
Commit
de055ec
·
1 Parent(s): 221ee46

Enable persistent SQLite storage for Hugging Face Spaces using the /data mount

Browse files
Files changed (1) hide show
  1. server/src/db/database.js +5 -1
server/src/db/database.js CHANGED
@@ -2,7 +2,11 @@ const sqlite3 = require('sqlite3').verbose();
2
  const { open } = require('sqlite');
3
  const path = require('path');
4
 
5
- const dbPath = path.resolve(__dirname, 'locations.sqlite');
 
 
 
 
6
 
7
  let dbInstance = null;
8
 
 
2
  const { open } = require('sqlite');
3
  const path = require('path');
4
 
5
+ // Hugging Face Persistent Storage path is typically at /data if configured in the Space settings
6
+ const PERSISTENT_DATA_PATH = '/data/locations.sqlite';
7
+ const LOCAL_DATA_PATH = path.resolve(__dirname, 'locations.sqlite');
8
+
9
+ const dbPath = require('fs').existsSync('/data') ? PERSISTENT_DATA_PATH : LOCAL_DATA_PATH;
10
 
11
  let dbInstance = null;
12