Bug 1649613 - Convert Sqlite.jsm to use PathUtils r=emalysz

Differential Revision: https://phabricator.services.mozilla.com/D99157
This commit is contained in:
Michael Goossens 2020-12-21 22:52:20 +00:00
Родитель 21cd9ed842
Коммит 21edf7e3de
1 изменённых файлов: 12 добавлений и 4 удалений

Просмотреть файл

@ -19,7 +19,6 @@ const { setTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm");
XPCOMUtils.defineLazyModuleGetters(this, {
AsyncShutdown: "resource://gre/modules/AsyncShutdown.jsm",
Services: "resource://gre/modules/Services.jsm",
OS: "resource://gre/modules/osfile.jsm",
Log: "resource://gre/modules/Log.jsm",
FileUtils: "resource://gre/modules/FileUtils.jsm",
PromiseUtils: "resource://gre/modules/PromiseUtils.jsm",
@ -1034,7 +1033,16 @@ function openConnection(options) {
}
// Retains absolute paths and normalizes relative as relative to profile.
let path = OS.Path.join(OS.Constants.Path.profileDir, options.path);
let path = options.path;
if (
!path.includes(Services.dirsvc.get("ProfD", Ci.nsIFile).path) &&
!path.includes(Services.dirsvc.get("CurWorkD", Ci.nsIFile).path)
) {
path = PathUtils.joinRelative(
Services.dirsvc.get("ProfD", Ci.nsIFile).path,
options.path
);
}
let sharedMemoryCache =
"sharedMemoryCache" in options ? options.sharedMemoryCache : true;
@ -1066,7 +1074,7 @@ function openConnection(options) {
}
let file = FileUtils.File(path);
let identifier = getIdentifierByFileName(OS.Path.basename(path));
let identifier = getIdentifierByFileName(PathUtils.filename(path));
log.info("Opening database: " + path + " (" + identifier + ")");
@ -1181,7 +1189,7 @@ function cloneStorageConnection(options) {
}
let path = source.databaseFile.path;
let identifier = getIdentifierByFileName(OS.Path.basename(path));
let identifier = getIdentifierByFileName(PathUtils.filename(path));
log.info("Cloning database: " + path + " (" + identifier + ")");