test suite now passes after OsPath conversion

The test suite was failing because of a bug in the Database/* modules.
I had replaced doesPathExist with doesDirectoryExist, but it was
checking the database file.

I have audited commit f1ba21d698 for
other changes to doesPathExist, and checked that doesDirectoryExist and
doesFileExist were used correctly.

The only change I found is in youtubeDl', where it used to return
directories that might have been created by youtube-dl. But it was
supposed to return media files, so changing it to use doesFileExist is
actually an improvement. Although only of theoretical benefit.

Note that it would actually be possible to keep using doesPathExist,
there is a version of that for OsPath as well. But the rest of these
changes seem safe.

Sponsored-by: Nicholas Golder-Manning
This commit is contained in:
Joey Hess 2025-02-11 12:37:09 -04:00
parent c85d5a0dc8
commit 5dbaaae299
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
6 changed files with 6 additions and 6 deletions

View file

@ -97,7 +97,7 @@ openDb :: Annex ContentIdentifierHandle
openDb = do openDb = do
dbdir <- calcRepo' gitAnnexContentIdentifierDbDir dbdir <- calcRepo' gitAnnexContentIdentifierDbDir
let db = dbdir </> literalOsPath "db" let db = dbdir </> literalOsPath "db"
isnew <- liftIO $ not <$> doesDirectoryExist db isnew <- liftIO $ not <$> doesFileExist db
if isnew if isnew
then initDb db $ void $ then initDb db $ void $
runMigrationSilent migrateContentIdentifier runMigrationSilent migrateContentIdentifier

View file

@ -97,7 +97,7 @@ openDb :: UUID -> Annex ExportHandle
openDb u = do openDb u = do
dbdir <- calcRepo' (gitAnnexExportDbDir u) dbdir <- calcRepo' (gitAnnexExportDbDir u)
let db = dbdir </> literalOsPath "db" let db = dbdir </> literalOsPath "db"
unlessM (liftIO $ doesDirectoryExist db) $ do unlessM (liftIO $ doesFileExist db) $ do
initDb db $ void $ initDb db $ void $
runMigrationSilent migrateExport runMigrationSilent migrateExport
h <- liftIO $ H.openDbQueue db "exported" h <- liftIO $ H.openDbQueue db "exported"

View file

@ -71,7 +71,7 @@ openDb :: UUID -> Annex FsckHandle
openDb u = do openDb u = do
dbdir <- calcRepo' (gitAnnexFsckDbDir u) dbdir <- calcRepo' (gitAnnexFsckDbDir u)
let db = dbdir </> literalOsPath "db" let db = dbdir </> literalOsPath "db"
unlessM (liftIO $ doesDirectoryExist db) $ do unlessM (liftIO $ doesFileExist db) $ do
initDb db $ void $ initDb db $ void $
runMigrationSilent migrateFsck runMigrationSilent migrateFsck
lockFileCached =<< calcRepo' (gitAnnexFsckDbLock u) lockFileCached =<< calcRepo' (gitAnnexFsckDbLock u)

View file

@ -74,7 +74,7 @@ openDb :: Annex ImportFeedDbHandle
openDb = do openDb = do
dbdir <- calcRepo' gitAnnexImportFeedDbDir dbdir <- calcRepo' gitAnnexImportFeedDbDir
let db = dbdir </> literalOsPath "db" let db = dbdir </> literalOsPath "db"
isnew <- liftIO $ not <$> doesDirectoryExist db isnew <- liftIO $ not <$> doesFileExist db
when isnew $ when isnew $
initDb db $ void $ initDb db $ void $
runMigrationSilent migrateImportFeed runMigrationSilent migrateImportFeed

View file

@ -129,7 +129,7 @@ openDb forwrite _ = do
catchPermissionDenied permerr $ withExclusiveLock lck $ do catchPermissionDenied permerr $ withExclusiveLock lck $ do
dbdir <- calcRepo' gitAnnexKeysDbDir dbdir <- calcRepo' gitAnnexKeysDbDir
let db = dbdir </> literalOsPath "db" let db = dbdir </> literalOsPath "db"
dbexists <- liftIO $ doesDirectoryExist db dbexists <- liftIO $ doesFileExist db
case dbexists of case dbexists of
True -> open db False True -> open db False
False -> do False -> do

View file

@ -106,7 +106,7 @@ openDb :: Annex RepoSizeHandle
openDb = lockDbWhile permerr $ do openDb = lockDbWhile permerr $ do
dbdir <- calcRepo' gitAnnexRepoSizeDbDir dbdir <- calcRepo' gitAnnexRepoSizeDbDir
let db = dbdir </> literalOsPath "db" let db = dbdir </> literalOsPath "db"
unlessM (liftIO $ doesDirectoryExist db) $ do unlessM (liftIO $ doesFileExist db) $ do
initDb db $ void $ initDb db $ void $
runMigrationSilent migrateRepoSizes runMigrationSilent migrateRepoSizes
h <- liftIO $ H.openDb db "repo_sizes" h <- liftIO $ H.openDb db "repo_sizes"