Revision 857cbfb1 src/Ganeti/Query/Server.hs

b/src/Ganeti/Query/Server.hs
63 63
import Ganeti.Query.Filter (makeSimpleFilter)
64 64
import Ganeti.Types
65 65
import qualified Ganeti.UDSServer as U (Handler(..), listener)
66
import Ganeti.Utils (lockFile, exitIfBad, watchFile)
66
import Ganeti.Utils (lockFile, exitIfBad, watchFile, safeRenameFile)
67 67
import qualified Ganeti.Version as Version
68 68

  
69 69
-- | Helper for classic queries.
......
347 347
                       let mcs = Config.getMasterCandidates cfg
348 348
                           live = liveJobFile qDir jid
349 349
                           archive = archivedJobFile qDir jid
350
                       renameResult <- try $ renameFile live archive
351
                                       :: IO (Either IOError ())
350
                       renameResult <- safeRenameFile live archive
352 351
                       putMVar qlock ()
353 352
                       case renameResult of
354
                         Left e -> return . Bad . JobQueueError
355
                                     $ "Archiving failed in an unexpected way: "
356
                                         ++ show e
357
                         Right () -> do
353
                         Bad s -> return . Bad . JobQueueError
354
                                    $ "Archiving failed in an unexpected way: "
355
                                        ++ s
356
                         Ok () -> do
358 357
                           _ <- executeRpcCall mcs
359 358
                                  $ RpcCallJobqueueRename [(live, archive)]
360 359
                           return . Ok $ showJSON True

Also available in: Unified diff