summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2024-06-30 16:41:18 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2024-06-30 16:41:18 +0200
commit47b8396c94af75832d96e4d3b4e0d7001ff70388 (patch)
tree0b601a7fc2747fe74b2b915297bc8c9ba6b5484f
parente4ab9a3270e4c29a556cdcea315a9a01477ed866 (diff)
Replace inotify with multiplatform fsnotify package
-rw-r--r--erebos.cabal2
-rw-r--r--src/Erebos/Storage.hs8
-rw-r--r--src/Erebos/Storage/Internal.hs4
3 files changed, 7 insertions, 7 deletions
diff --git a/erebos.cabal b/erebos.cabal
index 8a8f0bc..472811f 100644
--- a/erebos.cabal
+++ b/erebos.cabal
@@ -148,9 +148,9 @@ library
deepseq >= 1.4 && <1.6,
directory >= 1.3 && <1.4,
filepath >=1.4 && <1.6,
+ fsnotify ^>= { 0.4 },
hashable >=1.3 && <1.5,
hashtables >=1.2 && <1.4,
- hinotify >=0.4 && <0.5,
iproute >=1.7.12 && <1.8,
memory >=0.14 && <0.19,
mtl >=2.2 && <2.4,
diff --git a/src/Erebos/Storage.hs b/src/Erebos/Storage.hs
index 5730b4c..2e6653a 100644
--- a/src/Erebos/Storage.hs
+++ b/src/Erebos/Storage.hs
@@ -103,8 +103,8 @@ import qualified Data.UUID as U
import qualified Data.UUID.V4 as U
import System.Directory
+import System.FSNotify
import System.FilePath
-import System.INotify
import System.IO.Error
import System.IO.Unsafe
@@ -543,12 +543,12 @@ watchHeadRaw st tid hid sel cb = do
watched <- case stBacking st of
StorageDir { dirPath = spath, dirWatchers = mvar } -> modifyMVar mvar $ \(mbmanager, ilist, wl) -> do
- manager <- maybe initINotify return mbmanager
+ manager <- maybe startManager return mbmanager
ilist' <- case tid `elem` ilist of
True -> return ilist
False -> do
- void $ addWatch manager [ Move ] (BC.pack $ headTypePath spath tid) $ \case
- MovedIn { filePath = fpath } | Just ihid <- HeadID <$> U.fromASCIIBytes fpath -> do
+ void $ watchDir manager (headTypePath spath tid) (const True) $ \case
+ Added { eventPath = fpath } | Just ihid <- HeadID <$> U.fromString (takeFileName fpath) -> do
loadHeadRaw st tid ihid >>= \case
Just ref -> do
(_, _, iwl) <- readMVar mvar
diff --git a/src/Erebos/Storage/Internal.hs b/src/Erebos/Storage/Internal.hs
index b9cf6dd..d419a5e 100644
--- a/src/Erebos/Storage/Internal.hs
+++ b/src/Erebos/Storage/Internal.hs
@@ -31,8 +31,8 @@ import Data.UUID (UUID)
import Foreign.Storable (peek)
import System.Directory
+import System.FSNotify (WatchManager)
import System.FilePath
-import System.INotify (INotify)
import System.IO
import System.IO.Error
import System.IO.Unsafe (unsafePerformIO)
@@ -60,7 +60,7 @@ showParentStorage Storage { stParent = Just st } = "@" ++ show st
data StorageBacking c
= StorageDir { dirPath :: FilePath
- , dirWatchers :: MVar ( Maybe INotify, [ HeadTypeID ], WatchList c )
+ , dirWatchers :: MVar ( Maybe WatchManager, [ HeadTypeID ], WatchList c )
}
| StorageMemory { memHeads :: MVar [((HeadTypeID, HeadID), Ref' c)]
, memObjs :: MVar (Map RefDigest BL.ByteString)