From 5dbaaae299a6756b018a565260a79e95cacc473a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 11 Feb 2025 12:37:09 -0400 Subject: [PATCH] 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 f1ba21d698c908ad84c08bce24fbbc376190fe83 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 --- Database/ContentIdentifier.hs | 2 +- Database/Export.hs | 2 +- Database/Fsck.hs | 2 +- Database/ImportFeed.hs | 2 +- Database/Keys.hs | 2 +- Database/RepoSize.hs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Database/ContentIdentifier.hs b/Database/ContentIdentifier.hs index c531f915ea..4fdfd5b292 100644 --- a/Database/ContentIdentifier.hs +++ b/Database/ContentIdentifier.hs @@ -97,7 +97,7 @@ openDb :: Annex ContentIdentifierHandle openDb = do dbdir <- calcRepo' gitAnnexContentIdentifierDbDir let db = dbdir literalOsPath "db" - isnew <- liftIO $ not <$> doesDirectoryExist db + isnew <- liftIO $ not <$> doesFileExist db if isnew then initDb db $ void $ runMigrationSilent migrateContentIdentifier diff --git a/Database/Export.hs b/Database/Export.hs index 0ed6c126bb..71fbbec13d 100644 --- a/Database/Export.hs +++ b/Database/Export.hs @@ -97,7 +97,7 @@ openDb :: UUID -> Annex ExportHandle openDb u = do dbdir <- calcRepo' (gitAnnexExportDbDir u) let db = dbdir literalOsPath "db" - unlessM (liftIO $ doesDirectoryExist db) $ do + unlessM (liftIO $ doesFileExist db) $ do initDb db $ void $ runMigrationSilent migrateExport h <- liftIO $ H.openDbQueue db "exported" diff --git a/Database/Fsck.hs b/Database/Fsck.hs index 496903e0e4..50ba8f8c30 100644 --- a/Database/Fsck.hs +++ b/Database/Fsck.hs @@ -71,7 +71,7 @@ openDb :: UUID -> Annex FsckHandle openDb u = do dbdir <- calcRepo' (gitAnnexFsckDbDir u) let db = dbdir literalOsPath "db" - unlessM (liftIO $ doesDirectoryExist db) $ do + unlessM (liftIO $ doesFileExist db) $ do initDb db $ void $ runMigrationSilent migrateFsck lockFileCached =<< calcRepo' (gitAnnexFsckDbLock u) diff --git a/Database/ImportFeed.hs b/Database/ImportFeed.hs index 2d1611c73c..8820b84189 100644 --- a/Database/ImportFeed.hs +++ b/Database/ImportFeed.hs @@ -74,7 +74,7 @@ openDb :: Annex ImportFeedDbHandle openDb = do dbdir <- calcRepo' gitAnnexImportFeedDbDir let db = dbdir literalOsPath "db" - isnew <- liftIO $ not <$> doesDirectoryExist db + isnew <- liftIO $ not <$> doesFileExist db when isnew $ initDb db $ void $ runMigrationSilent migrateImportFeed diff --git a/Database/Keys.hs b/Database/Keys.hs index 686be30e13..cc3f189b99 100644 --- a/Database/Keys.hs +++ b/Database/Keys.hs @@ -129,7 +129,7 @@ openDb forwrite _ = do catchPermissionDenied permerr $ withExclusiveLock lck $ do dbdir <- calcRepo' gitAnnexKeysDbDir let db = dbdir literalOsPath "db" - dbexists <- liftIO $ doesDirectoryExist db + dbexists <- liftIO $ doesFileExist db case dbexists of True -> open db False False -> do diff --git a/Database/RepoSize.hs b/Database/RepoSize.hs index 93c6b1d5ba..d70de72191 100644 --- a/Database/RepoSize.hs +++ b/Database/RepoSize.hs @@ -106,7 +106,7 @@ openDb :: Annex RepoSizeHandle openDb = lockDbWhile permerr $ do dbdir <- calcRepo' gitAnnexRepoSizeDbDir let db = dbdir literalOsPath "db" - unlessM (liftIO $ doesDirectoryExist db) $ do + unlessM (liftIO $ doesFileExist db) $ do initDb db $ void $ runMigrationSilent migrateRepoSizes h <- liftIO $ H.openDb db "repo_sizes"