493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
|
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
|
+
+
+
+
+
-
+
+
+
|
(if (eq? tries-left 2)
(begin
(dbfile:print-err "INFO: forcing journal rollup "busy-file)
(dbfile:brute-force-salvage-db fname)))
(dbfile:cautious-open-database fname init-proc (- tries-left 1)))
(let* ((db-exists (file-exists? fname))
(result (condition-case
(let* ((nosyncdb *no-sync-db*)
(lockname (conc fname ".lock"))
(db (begin
(dbfile:simple-file-lock-and-wait lockname expire-time: 5)
(if nosyncdb (db:no-sync-get-lock nosyncdb fname))
(let* ((db (sqlite3:open-database fname)))
(sqlite3:open-database fname))))
(if (and init-proc (not db-exists))
(init-proc db))
(if nosyncdb (db:no-sync-del! nosyncdb fname))
(dbfile:simple-file-release-lock lockname)
db)
(exn (io-error)
(dbfile:print-err exn "ERROR: i/o error with " fname ". Check permissions, disk space etc. and try again.")
(retry))
(exn (corrupt)
(dbfile:print-err exn "ERROR: database " fname " is corrupt. Repair it to proceed.")
(retry))
|