cleanup thanks to Utility.PID
This commit is contained in:
parent
c390e896d1
commit
7b19c7d25b
5 changed files with 18 additions and 34 deletions
|
@ -16,6 +16,7 @@ import Assistant.NamedThread
|
|||
import Utility.ThreadScheduler
|
||||
import Utility.NotificationBroadcaster
|
||||
import Utility.Url
|
||||
import Utility.PID
|
||||
import qualified Git.Construct
|
||||
import qualified Git.Config
|
||||
import Config.Files
|
||||
|
@ -25,9 +26,8 @@ import qualified Git
|
|||
import Control.Concurrent
|
||||
import System.Process (cwd)
|
||||
#ifndef mingw32_HOST_OS
|
||||
import System.Posix (getProcessID, signalProcess, sigTERM)
|
||||
import System.Posix (signalProcess, sigTERM)
|
||||
#else
|
||||
import System.Win32.Process.Current (getCurrentProcessId)
|
||||
import System.Win32.Console (generateConsoleCtrlEvent, cTRL_C_EVENT)
|
||||
#endif
|
||||
|
||||
|
@ -53,9 +53,9 @@ postRestart url = do
|
|||
void $ liftIO $ forkIO $ do
|
||||
threadDelaySeconds (Seconds 120)
|
||||
#ifndef mingw32_HOST_OS
|
||||
signalProcess sigTERM =<< getProcessID
|
||||
signalProcess sigTERM =<< getPID
|
||||
#else
|
||||
generateConsoleCtrlEvent cTRL_C_EVENT =<< getCurrentProcessId
|
||||
generateConsoleCtrlEvent cTRL_C_EVENT =<< getPID
|
||||
#endif
|
||||
|
||||
runRestart :: Assistant URLString
|
||||
|
|
|
@ -16,14 +16,14 @@ import Assistant.TransferSlots
|
|||
import Assistant.Restart
|
||||
import Utility.LogFile
|
||||
import Utility.NotificationBroadcaster
|
||||
import Utility.PID
|
||||
|
||||
import Control.Concurrent
|
||||
import qualified Data.Map as M
|
||||
import qualified Data.Text as T
|
||||
#ifndef mingw32_HOST_OS
|
||||
import System.Posix (getProcessID, signalProcess, sigTERM)
|
||||
import System.Posix (signalProcess, sigTERM)
|
||||
#else
|
||||
import System.Win32.Process.Current (getCurrentProcessId)
|
||||
import System.Win32.Console (generateConsoleCtrlEvent, cTRL_C_EVENT)
|
||||
#endif
|
||||
|
||||
|
@ -54,9 +54,9 @@ getShutdownConfirmedR = do
|
|||
void $ liftIO $ forkIO $ do
|
||||
threadDelay 2000000
|
||||
#ifndef mingw32_HOST_OS
|
||||
signalProcess sigTERM =<< getProcessID
|
||||
signalProcess sigTERM =<< getPID
|
||||
#else
|
||||
generateConsoleCtrlEvent cTRL_C_EVENT =<< getCurrentProcessId
|
||||
generateConsoleCtrlEvent cTRL_C_EVENT =<< getPID
|
||||
#endif
|
||||
redirect NotRunningR
|
||||
|
||||
|
|
|
@ -31,12 +31,8 @@ import Config
|
|||
import Types.Key
|
||||
import Utility.HumanTime
|
||||
import Git.FilePath
|
||||
import Utility.PID
|
||||
|
||||
#ifndef mingw32_HOST_OS
|
||||
import System.Posix.Process (getProcessID)
|
||||
#else
|
||||
import System.Win32.Process.Current (getCurrentProcessId)
|
||||
#endif
|
||||
import Data.Time.Clock.POSIX
|
||||
import Data.Time
|
||||
import System.Posix.Types (EpochTime)
|
||||
|
@ -149,14 +145,10 @@ performRemote key file backend numcopies remote =
|
|||
, checkKeyNumCopies key file numcopies
|
||||
]
|
||||
withtmp a = do
|
||||
#ifndef mingw32_HOST_OS
|
||||
v <- liftIO getProcessID
|
||||
#else
|
||||
v <- liftIO getCurrentProcessId
|
||||
#endif
|
||||
pid <- liftIO getPID
|
||||
t <- fromRepo gitAnnexTmpDir
|
||||
createAnnexDirectory t
|
||||
let tmp = t </> "fsck" ++ show v ++ "." ++ keyFile key
|
||||
let tmp = t </> "fsck" ++ show pid ++ "." ++ keyFile key
|
||||
let cleanup = liftIO $ catchIO (removeFile tmp) (const noop)
|
||||
cleanup
|
||||
cleanup `after` a tmp
|
||||
|
|
|
@ -18,14 +18,6 @@ module Remote.Rsync (
|
|||
RsyncOpts
|
||||
) where
|
||||
|
||||
import qualified Data.ByteString.Lazy as L
|
||||
import qualified Data.Map as M
|
||||
#ifndef mingw32_HOST_OS
|
||||
import System.Posix.Process (getProcessID)
|
||||
#else
|
||||
import System.Win32.Process.Current (getCurrentProcessId)
|
||||
#endif
|
||||
|
||||
import Common.Annex
|
||||
import Types.Remote
|
||||
import qualified Git
|
||||
|
@ -40,10 +32,14 @@ import Crypto
|
|||
import Utility.Rsync
|
||||
import Utility.CopyFile
|
||||
import Utility.Metered
|
||||
import Utility.PID
|
||||
import Annex.Perms
|
||||
import Logs.Transfer
|
||||
import Types.Creds
|
||||
|
||||
import qualified Data.ByteString.Lazy as L
|
||||
import qualified Data.Map as M
|
||||
|
||||
type RsyncUrl = String
|
||||
|
||||
data RsyncOpts = RsyncOpts
|
||||
|
@ -250,14 +246,10 @@ sendParams = ifM crippledFileSystem
|
|||
- up trees for rsync. -}
|
||||
withRsyncScratchDir :: (FilePath -> Annex a) -> Annex a
|
||||
withRsyncScratchDir a = do
|
||||
#ifndef mingw32_HOST_OS
|
||||
v <- liftIO getProcessID
|
||||
#else
|
||||
v <- liftIO getCurrentProcessId
|
||||
#endif
|
||||
p <- liftIO getPID
|
||||
t <- fromRepo gitAnnexTmpDir
|
||||
createAnnexDirectory t
|
||||
let tmp = t </> "rsynctmp" </> show v
|
||||
let tmp = t </> "rsynctmp" </> show p
|
||||
nuke tmp
|
||||
liftIO $ createDirectoryIfMissing True tmp
|
||||
nuke tmp `after` a tmp
|
||||
|
|
|
@ -20,7 +20,7 @@ import System.Posix
|
|||
import Control.Concurrent.Async
|
||||
#else
|
||||
import System.PosixCompat.Types
|
||||
import System.Win32.Console (generateConsoleCtrlEvent, cTRL_C_EVENT
|
||||
import System.Win32.Console (generateConsoleCtrlEvent, cTRL_C_EVENT)
|
||||
#endif
|
||||
|
||||
#ifndef mingw32_HOST_OS
|
||||
|
|
Loading…
Reference in a new issue