Skip to content

Commit 099af34

Browse files
authored
Remove likely unused FS.loadFilesFromDB and FS.saveFilesToDB helpers (#19049)
These were added back in 1b134c8 but we are not aware of anyone using them. We have a separate IDBFS filesystem that provides indexDB persistence so this seems like duplicate/redundant code. Fixes: #19025
1 parent 4e15675 commit 099af34

File tree

7 files changed

+3
-150
lines changed

7 files changed

+3
-150
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works.
2020

2121
3.1.35 (in development)
2222
-----------------------
23+
- `FS.loadFilesFromDB` and `FS.saveFilesToDB` were removed. We think it's
24+
unlikly there were any users of these functions since there is now a separate
25+
IDBFS filesystem for folks that want persistence. (#19049)
2326
- `allocateUTF8` library function moved to `library_legacy.js`. Prefer the
2427
more accurately named `stringToNewUTF8`.
2528
- `SDL_image` port was updated to version 2.6.0.

site/source/docs/api_reference/advanced-apis.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ example, writing a new local file system) or legacy file system compatibility.
9898
.. js:function:: FS.quit()
9999
.. js:function:: FS.indexedDB()
100100
.. js:function:: FS.DB_NAME()
101-
.. js:function:: FS.saveFilesToDB(paths, onload, onerror)
102-
.. js:function:: FS.loadFilesFromDB(paths, onload, onerror)
103101

104102
For advanced users only.
105103

src/library_fs.js

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,89 +1911,6 @@ FS.staticInit();` +
19111911
}
19121912
},
19131913

1914-
//
1915-
// persistence
1916-
//
1917-
indexedDB: () => {
1918-
return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
1919-
},
1920-
1921-
DB_NAME: () => {
1922-
return 'EM_FS_' + window.location.pathname;
1923-
},
1924-
DB_VERSION: 20,
1925-
DB_STORE_NAME: 'FILE_DATA',
1926-
1927-
// asynchronously saves a list of files to an IndexedDB. The DB will be created if not already existing.
1928-
saveFilesToDB: (paths, onload = (() => {}), onerror = (() => {})) => {
1929-
var indexedDB = FS.indexedDB();
1930-
try {
1931-
var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
1932-
} catch (e) {
1933-
return onerror(e);
1934-
}
1935-
openRequest.onupgradeneeded = () => {
1936-
out('creating db');
1937-
var db = openRequest.result;
1938-
db.createObjectStore(FS.DB_STORE_NAME);
1939-
};
1940-
openRequest.onsuccess = () => {
1941-
var db = openRequest.result;
1942-
var transaction = db.transaction([FS.DB_STORE_NAME], 'readwrite');
1943-
var files = transaction.objectStore(FS.DB_STORE_NAME);
1944-
var ok = 0, fail = 0, total = paths.length;
1945-
function finish() {
1946-
if (fail == 0) onload(); else onerror();
1947-
}
1948-
paths.forEach((path) => {
1949-
var putRequest = files.put(FS.analyzePath(path).object.contents, path);
1950-
putRequest.onsuccess = () => { ok++; if (ok + fail == total) finish() };
1951-
putRequest.onerror = () => { fail++; if (ok + fail == total) finish() };
1952-
});
1953-
transaction.onerror = onerror;
1954-
};
1955-
openRequest.onerror = onerror;
1956-
},
1957-
1958-
// asynchronously loads a file from IndexedDB.
1959-
loadFilesFromDB: (paths, onload = (() => {}), onerror = (() => {})) => {
1960-
var indexedDB = FS.indexedDB();
1961-
try {
1962-
var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
1963-
} catch (e) {
1964-
return onerror(e);
1965-
}
1966-
openRequest.onupgradeneeded = onerror; // no database to load from
1967-
openRequest.onsuccess = () => {
1968-
var db = openRequest.result;
1969-
try {
1970-
var transaction = db.transaction([FS.DB_STORE_NAME], 'readonly');
1971-
} catch(e) {
1972-
onerror(e);
1973-
return;
1974-
}
1975-
var files = transaction.objectStore(FS.DB_STORE_NAME);
1976-
var ok = 0, fail = 0, total = paths.length;
1977-
function finish() {
1978-
if (fail == 0) onload(); else onerror();
1979-
}
1980-
paths.forEach((path) => {
1981-
var getRequest = files.get(path);
1982-
getRequest.onsuccess = () => {
1983-
if (FS.analyzePath(path).exists) {
1984-
FS.unlink(path);
1985-
}
1986-
FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true);
1987-
ok++;
1988-
if (ok + fail == total) finish();
1989-
};
1990-
getRequest.onerror = () => { fail++; if (ok + fail == total) finish() };
1991-
});
1992-
transaction.onerror = onerror;
1993-
};
1994-
openRequest.onerror = onerror;
1995-
},
1996-
19971914
// Removed v1 functions
19981915
#if ASSERTIONS
19991916
absolutePath: () => {

src/preamble.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,6 @@ var FS = {
512512
mkdev: function() { FS.error() },
513513
registerDevice: function() { FS.error() },
514514
analyzePath: function() { FS.error() },
515-
loadFilesFromDB: function() { FS.error() },
516515

517516
ErrnoError: function ErrnoError() { FS.error() },
518517
};

test/file_db.cpp

Lines changed: 0 additions & 52 deletions
This file was deleted.

test/test_browser.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,17 +1345,6 @@ def test_write_file_in_environment_web(self):
13451345
def test_fflush(self):
13461346
self.btest('test_fflush.cpp', '0', args=['-sEXIT_RUNTIME', '--shell-file', test_file('test_fflush.html')], reporting=Reporting.NONE)
13471347

1348-
def test_file_db(self):
1349-
secret = str(time.time())
1350-
create_file('moar.txt', secret)
1351-
self.btest('file_db.cpp', '1', args=['--preload-file', 'moar.txt', '-DFIRST'])
1352-
shutil.copyfile('test.html', 'first.html')
1353-
self.btest('file_db.cpp', secret, args=['-sFORCE_FILESYSTEM'])
1354-
shutil.copyfile('test.html', 'second.html')
1355-
create_file('moar.txt', 'aliantha')
1356-
self.btest('file_db.cpp', secret, args=['--preload-file', 'moar.txt']) # even with a file there, we load over it
1357-
shutil.move('test.html', 'third.html')
1358-
13591348
def test_fs_idbfs_sync(self):
13601349
self.set_setting('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE', '$ccall')
13611350
for extra in [[], ['-DEXTRA_WORK']]:

test/test_other.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7497,7 +7497,6 @@ def test(contents):
74977497
test("FS.createPreloadedFile('waka waka, just warning check')")
74987498
test("FS.createDataFile('waka waka, just warning check')")
74997499
test("FS.analyzePath('waka waka, just warning check')")
7500-
test("FS.loadFilesFromDB('waka waka, just warning check')")
75017500
# might appear in filesystem code from a separate script tag
75027501
test("Module['FS_createDataFile']('waka waka, just warning check')")
75037502
test("Module['FS_createPreloadedFile']('waka waka, just warning check')")

0 commit comments

Comments
 (0)