Skip to content

Commit bd7e238

Browse files
committed
fix: allow non existent SQLite files, only complain when its *path* does not exist
Refs #2437
1 parent fc269c6 commit bd7e238

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

source/dbconnection.pas

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2984,6 +2984,7 @@ procedure TSQLiteConnection.SetActive(Value: Boolean);
29842984
ErrorHint: String;
29852985
FileNames, EncryptionParams: TStringList;
29862986
MainFile, DbAlias, Param, ParamName: String;
2987+
MainFileDir: String;
29872988
i, SplitPos, ParamValue: Integer;
29882989
CipherIndex, ConfigResult: Integer;
29892990
ParamWasSet: Boolean;
@@ -2994,8 +2995,12 @@ procedure TSQLiteConnection.SetActive(Value: Boolean);
29942995

29952996
if Value then begin
29962997
// Fixes "out of memory" crash in sqlite3_open, see issue #1367
2998+
MainFileDir := ExtractFilePath(MainFile);
2999+
MainFileDir := IncludeTrailingPathDelimiter(MainFileDir);
3000+
if not DirectoryExists(MainFileDir) then
3001+
raise EDbError.Create(f_('Folder in path does not exist: %s', [MainFile]));
29973002
if not FileExists(MainFile) then
2998-
raise EDbError.Create(f_('File does not exist: %s', [MainFile]));
3003+
Log(lcInfo, f_('File does not yet exist, will be created now: %s', [MainFile]));
29993004

30003005
DoBeforeConnect;
30013006

0 commit comments

Comments
 (0)