Skip to content

Commit

Permalink
matchFileGlob should only monitor for existence
Browse files Browse the repository at this point in the history
Since the matchFileGlob function returns names of files and not content,
actions using it don't actually depend on the content, so it's more
consistent not to monitor the content.

In particular, following Edward's recent fix, the code that reads the
package cabal files already monitors the content. This is the
appropriate separation of concerns, the code that finds the .cabal files
monitors the search glob for file existence, while the code that reads
the .cabal files monitors the file content.
  • Loading branch information
dcoutts committed Apr 17, 2016
1 parent fcb61b7 commit ed1cc2f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions cabal-install/Distribution/Client/FileMonitor.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module Distribution.Client.FileMonitor (
monitorDirectoryExistence,
monitorFileOrDirectory,
monitorFileGlob,
monitorFileGlobExistence,
monitorFileSearchPath,
monitorFileHashedSearchPath,

Expand Down Expand Up @@ -156,6 +157,13 @@ monitorFileOrDirectory = MonitorFile FileModTime DirModTime
monitorFileGlob :: FilePathGlob -> MonitorFilePath
monitorFileGlob = MonitorFileGlob FileHashed DirExists

-- | Monitor a set of files (or directories) identified by a file glob for
-- existence only. The monitored glob is considered to have changed if the set
-- of files matching the glob changes (i.e. creations or deletions).
--
monitorFileGlobExistence :: FilePathGlob -> MonitorFilePath
monitorFileGlobExistence = MonitorFileGlob FileExists DirExists

-- | Creates a list of files to monitor when you search for a file which
-- unsuccessfully looked in @notFoundAtPaths@ before finding it at
-- @foundAtPath@.
Expand Down
3 changes: 2 additions & 1 deletion cabal-install/Distribution/Client/RebuildMonad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module Distribution.Client.RebuildMonad (
monitorFileHashedSearchPath,
-- ** Monitoring file globs
monitorFileGlob,
monitorFileGlobExistence,
FilePathGlob(..),
FilePathRoot(..),
FilePathGlobRel(..),
Expand Down Expand Up @@ -140,6 +141,6 @@ rerunIfChanged verbosity monitor key action = do
matchFileGlob :: FilePathGlob -> Rebuild [FilePath]
matchFileGlob glob = do
root <- askRoot
monitorFiles [monitorFileGlob glob]
monitorFiles [monitorFileGlobExistence glob]
liftIO $ Glob.matchFileGlob root glob

0 comments on commit ed1cc2f

Please sign in to comment.