wip - logs

This commit is contained in:
spaced4ndy
2023-04-24 18:42:30 +04:00
parent 9edefb5a56
commit 4a64061aab
3 changed files with 10 additions and 3 deletions
+6 -2
View File
@@ -390,6 +390,8 @@ runXFTPSndPrepareWorker c doWork = do
else pure sndFile
maxRecipients <- asks (xftpMaxRecipientsPerRequest . config)
let numRecipients' = min numRecipients maxRecipients
liftIO $ print "finished encrypting"
threadDelay 10000000
-- concurrently?
forM_ (filter (not . chunkCreated) chunks) $ createChunk numRecipients'
withStore' c $ \db -> updateSndFileStatus db sndFileId SFSUploading
@@ -463,7 +465,7 @@ runXFTPSndWorker c srv doWork = do
`catchError` \e -> retryOnError "XFTP snd worker" (retryLoop loop e delay') (retryDone e) e
where
retryLoop loop e replicaDelay = do
liftIO $ print $ "replica " <> show sndChunkReplicaId <> " temporary error"
liftIO $ print $ "replica " <> show sndChunkReplicaId <> " temporary error" <> show e
flip catchError (\_ -> pure ()) $ do
notifyOnRetry <- asks (xftpNotifyErrsOnRetry . config)
when notifyOnRetry $ notify c sndFileEntityId $ SFERR e
@@ -471,7 +473,9 @@ runXFTPSndWorker c srv doWork = do
withStore' c $ \db -> updateSndChunkReplicaDelay db sndChunkReplicaId replicaDelay
atomically $ assertAgentForeground c
loop
retryDone e = sndWorkerInternalError c sndFileId sndFileEntityId (Just filePrefixPath) (show e)
retryDone e = do
liftIO $ print $ "replica " <> show sndChunkReplicaId <> " permanent error" <> show e
sndWorkerInternalError c sndFileId sndFileEntityId (Just filePrefixPath) (show e)
uploadFileChunk :: SndFileChunk -> SndFileChunkReplica -> m ()
uploadFileChunk sndFileChunk@SndFileChunk {sndFileId, userId, chunkSpec = chunkSpec@XFTPChunkSpec {filePath}, digest = chunkDigest} replica = do
replica'@SndFileChunkReplica {sndChunkReplicaId} <- addRecipients sndFileChunk replica
+3 -1
View File
@@ -146,7 +146,9 @@ sendXFTPCommand XFTPClient {config, http2Client = http2@HTTP2Client {sessionId}}
Just e -> throwError $ PCEProtocolError e
_ -> pure (r, body)
Left e -> throwError $ PCEResponseError e
HTTP2RequestError e -> throwError $ PCEInternalError $ show e
HTTP2RequestError e -> do
liftIO $ print $ "in sendXFTPCommand HTTP2RequestError" <> show e
throwError $ PCEInternalError $ show e
where
streamBody :: ByteString -> (Builder -> IO ()) -> IO () -> IO ()
streamBody t send done = do
@@ -118,6 +118,7 @@ getVerifiedHTTP2Client proxyUsername host port keyHash caStore config@HTTP2Clien
process HTTP2Client {client_ = HClient {reqQ}} sendReq = forever $ do
(req, resVar) <- atomically $ readTBQueue reqQ
sendReq req (processResp resVar) `E.catch` \e -> do
liftIO $ print $ "in process catch e: " <> show e
let res = HTTP2RequestError e
atomically $ putTMVar resVar res
pure res