test suite now passes after OsPath conversion
authorJoey Hess <joeyh@joeyh.name>
Tue, 11 Feb 2025 16:37:09 +0000 (12:37 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 11 Feb 2025 16:44:09 +0000 (12:44 -0400)
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
Database/Export.hs
Database/Fsck.hs
Database/ImportFeed.hs
Database/Keys.hs
Database/RepoSize.hs

index c531f915ea5e99fb68b222d26e9bc48ebf7b83d4..4fdfd5b292608b5afb6cdd9a10f6a4887fe79014 100644 (file)
@@ -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
index 0ed6c126bb9e0fe25ba032f907456cc8cdda9cf0..71fbbec13d1f3a0b6e61a7ac6f1ec26f0521da3d 100644 (file)
@@ -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"
index 496903e0e4614b7379ddd48a24d38f23306a94b1..50ba8f8c302d4b29b0f60a2fa7777636e5cabd53 100644 (file)
@@ -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)
index 2d1611c73c9fe183928f096c4513042bd5722e0a..8820b8418934eed011c521d13f8536f6a78ed3ea 100644 (file)
@@ -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
index 686be30e1395e3c1e59dc9d10b75a0182f0f1716..cc3f189b993b31b389c4c548842c461dbb8a2527 100644 (file)
@@ -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
index 93c6b1d5ba727c7dcd427e1e6f275f2e6d479eb6..d70de721918f0b8383bede33aca74f3d2a25dcb2 100644 (file)
@@ -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"