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

Refine persistent storage path logic for HF Spaces

Browse files
Files changed (1) hide show
  1. server/src/db/database.js +6 -4
server/src/db/database.js CHANGED
@@ -2,11 +2,13 @@ const sqlite3 = require('sqlite3').verbose();
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
 
 
2
  const { open } = require('sqlite');
3
  const path = require('path');
4
 
5
+ const fs = require('fs');
 
 
6
 
7
+ // Hugging Face Persistent Storage path
8
+ const PERSISTENT_DIR = '/data';
9
+ const dbPath = fs.existsSync(PERSISTENT_DIR)
10
+ ? path.join(PERSISTENT_DIR, 'locations.sqlite')
11
+ : path.resolve(__dirname, 'locations.sqlite');
12
 
13
  let dbInstance = null;
14