LGTM, thanks
On Tue, Dec 10, 2013 at 10:46 AM, Klaus Aehlig <[email protected]> wrote: > The function getFStat causes an IOError if the file to be stated does > not exist. In some cases, however, the only thing we care about is whether > it has changed, with disappearing being a legitimate change. So add a > wrapper > that catches the IOError and returns nullFStat. > > Signed-off-by: Klaus Aehlig <[email protected]> > --- > src/Ganeti/Utils.hs | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/src/Ganeti/Utils.hs b/src/Ganeti/Utils.hs > index 3ebd103..72f86ef 100644 > --- a/src/Ganeti/Utils.hs > +++ b/src/Ganeti/Utils.hs > @@ -68,6 +68,7 @@ module Ganeti.Utils > , FStat > , nullFStat > , getFStat > + , getFStatSafe > , needsReload > ) where > > @@ -568,6 +569,11 @@ buildFileStatus ofs = > getFStat :: FilePath -> IO FStat > getFStat p = liftM buildFileStatus (getFileStatus p) > > +-- | Safe version of 'getFStat', that ignores IOErrors. > +getFStatSafe :: FilePath -> IO FStat > +getFStatSafe fpath = liftM (either (const nullFStat) id) > + ((try $ getFStat fpath) :: IO (Either IOError > FStat)) > + > -- | Check if the file needs reloading > needsReload :: FStat -> FilePath -> IO (Maybe FStat) > needsReload oldstat path = do > -- > 1.8.5.1 > >
