avoid head
This commit is contained in:
		
					parent
					
						
							
								0833eb43a6
							
						
					
				
			
			
				commit
				
					
						ac71ab7bd7
					
				
			
		
					 2 changed files with 7 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -98,11 +98,11 @@ checkMountMonitor :: Client -> IO Bool
 | 
			
		|||
checkMountMonitor client = do
 | 
			
		||||
	running <- filter (`elem` usableservices)
 | 
			
		||||
		<$> listServiceNames client
 | 
			
		||||
	if null running
 | 
			
		||||
		then startOneService client startableservices
 | 
			
		||||
		else do
 | 
			
		||||
	case running of
 | 
			
		||||
		[] -> startOneService client startableservices
 | 
			
		||||
		(service:_) -> do
 | 
			
		||||
			debug thisThread [ "Using running DBUS service"
 | 
			
		||||
				, Prelude.head running
 | 
			
		||||
				, service
 | 
			
		||||
				, "to monitor mount events."
 | 
			
		||||
				]
 | 
			
		||||
			return True
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -67,7 +67,9 @@ runWebApp app observer = do
 | 
			
		|||
localSocket :: IO Socket
 | 
			
		||||
localSocket = do
 | 
			
		||||
	addrs <- getAddrInfo (Just hints) (Just localhost) Nothing
 | 
			
		||||
	go $ Prelude.head addrs
 | 
			
		||||
	case addrs of
 | 
			
		||||
		[] -> error "unable to bind to a local socket"
 | 
			
		||||
		(addr:_) -> go addr
 | 
			
		||||
	where
 | 
			
		||||
		hints = defaultHints
 | 
			
		||||
			{ addrFlags = [AI_ADDRCONFIG]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue