On Thu, Nov 7, 2013 at 1:20 PM, Klaus Aehlig <[email protected]> wrote: > This function writes a (non-archived) job to disk. The file > name can be computed from the job id, which is part of the job. > > Signed-off-by: Klaus Aehlig <[email protected]> > --- > src/Ganeti/JQueue.hs | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/src/Ganeti/JQueue.hs b/src/Ganeti/JQueue.hs > index 6f99e26..ebb9e43 100644 > --- a/src/Ganeti/JQueue.hs > +++ b/src/Ganeti/JQueue.hs > @@ -48,6 +48,7 @@ module Ganeti.JQueue > , readSerialFromDisk > , allocateJobIds > , allocateJobId > + , writeJobToDisk > ) where > > import Control.Concurrent.MVar > @@ -337,6 +338,14 @@ loadJobFromDisk rootdir archived jid = do > liftM (\qj -> (qj, arch)) . > fromJResult "Parsing job file" $ Text.JSON.decode str > > +-- | Write a job to disk. > +writeJobToDisk :: FilePath -> QueuedJob -> IO (Result ()) > +writeJobToDisk rootdir job = do > + let filename = liveJobFile rootdir . qjId $ job > + content = Text.JSON.encode . Text.JSON.showJSON $ job > + tryAndLogIOError (atomicWriteFile filename content) > + ("Failed to write " ++ filename) Ok > + > -- | Read the job serial number from disk. > readSerialFromDisk :: IO (Result JobId) > readSerialFromDisk = do > -- > 1.8.4.1 >
LGTM, thanks. Michele -- Google Germany GmbH Dienerstr. 12 80331 München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores
