Spaces:
Running
Running
Enable persistent SQLite storage for Hugging Face Spaces using the /data mount
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
|