@@ -20,6 +20,7 @@ data FileServerStats = FileServerStats
2020 filesUploaded :: IORef Int ,
2121 filesExpired :: IORef Int ,
2222 filesDeleted :: IORef Int ,
23+ filesBlocked :: IORef Int ,
2324 filesDownloaded :: PeriodStats ,
2425 fileDownloads :: IORef Int ,
2526 fileDownloadAcks :: IORef Int ,
@@ -34,6 +35,7 @@ data FileServerStatsData = FileServerStatsData
3435 _filesUploaded :: Int ,
3536 _filesExpired :: Int ,
3637 _filesDeleted :: Int ,
38+ _filesBlocked :: Int ,
3739 _filesDownloaded :: PeriodStatsData ,
3840 _fileDownloads :: Int ,
3941 _fileDownloadAcks :: Int ,
@@ -50,12 +52,13 @@ newFileServerStats ts = do
5052 filesUploaded <- newIORef 0
5153 filesExpired <- newIORef 0
5254 filesDeleted <- newIORef 0
55+ filesBlocked <- newIORef 0
5356 filesDownloaded <- newPeriodStats
5457 fileDownloads <- newIORef 0
5558 fileDownloadAcks <- newIORef 0
5659 filesCount <- newIORef 0
5760 filesSize <- newIORef 0
58- pure FileServerStats {fromTime, filesCreated, fileRecipients, filesUploaded, filesExpired, filesDeleted, filesDownloaded, fileDownloads, fileDownloadAcks, filesCount, filesSize}
61+ pure FileServerStats {fromTime, filesCreated, fileRecipients, filesUploaded, filesExpired, filesDeleted, filesBlocked, filesDownloaded, fileDownloads, fileDownloadAcks, filesCount, filesSize}
5962
6063getFileServerStatsData :: FileServerStats -> IO FileServerStatsData
6164getFileServerStatsData s = do
@@ -65,12 +68,13 @@ getFileServerStatsData s = do
6568 _filesUploaded <- readIORef $ filesUploaded s
6669 _filesExpired <- readIORef $ filesExpired s
6770 _filesDeleted <- readIORef $ filesDeleted s
71+ _filesBlocked <- readIORef $ filesBlocked s
6872 _filesDownloaded <- getPeriodStatsData $ filesDownloaded s
6973 _fileDownloads <- readIORef $ fileDownloads s
7074 _fileDownloadAcks <- readIORef $ fileDownloadAcks s
7175 _filesCount <- readIORef $ filesCount s
7276 _filesSize <- readIORef $ filesSize s
73- pure FileServerStatsData {_fromTime, _filesCreated, _fileRecipients, _filesUploaded, _filesExpired, _filesDeleted, _filesDownloaded, _fileDownloads, _fileDownloadAcks, _filesCount, _filesSize}
77+ pure FileServerStatsData {_fromTime, _filesCreated, _fileRecipients, _filesUploaded, _filesExpired, _filesDeleted, _filesBlocked, _filesDownloaded, _fileDownloads, _fileDownloadAcks, _filesCount, _filesSize}
7478
7579-- this function is not thread safe, it is used on server start only
7680setFileServerStats :: FileServerStats -> FileServerStatsData -> IO ()
@@ -81,21 +85,23 @@ setFileServerStats s d = do
8185 writeIORef (filesUploaded s) $! _filesUploaded d
8286 writeIORef (filesExpired s) $! _filesExpired d
8387 writeIORef (filesDeleted s) $! _filesDeleted d
88+ writeIORef (filesBlocked s) $! _filesBlocked d
8489 setPeriodStats (filesDownloaded s) $! _filesDownloaded d
8590 writeIORef (fileDownloads s) $! _fileDownloads d
8691 writeIORef (fileDownloadAcks s) $! _fileDownloadAcks d
8792 writeIORef (filesCount s) $! _filesCount d
8893 writeIORef (filesSize s) $! _filesSize d
8994
9095instance StrEncoding FileServerStatsData where
91- strEncode FileServerStatsData {_fromTime, _filesCreated, _fileRecipients, _filesUploaded, _filesExpired, _filesDeleted, _filesDownloaded, _fileDownloads, _fileDownloadAcks, _filesCount, _filesSize} =
96+ strEncode FileServerStatsData {_fromTime, _filesCreated, _fileRecipients, _filesUploaded, _filesExpired, _filesDeleted, _filesBlocked, _filesDownloaded, _fileDownloads, _fileDownloadAcks, _filesCount, _filesSize} =
9297 B. unlines
9398 [ " fromTime=" <> strEncode _fromTime,
9499 " filesCreated=" <> strEncode _filesCreated,
95100 " fileRecipients=" <> strEncode _fileRecipients,
96101 " filesUploaded=" <> strEncode _filesUploaded,
97102 " filesExpired=" <> strEncode _filesExpired,
98103 " filesDeleted=" <> strEncode _filesDeleted,
104+ " filesBlocked=" <> strEncode _filesBlocked,
99105 " filesCount=" <> strEncode _filesCount,
100106 " filesSize=" <> strEncode _filesSize,
101107 " filesDownloaded:" ,
@@ -110,9 +116,10 @@ instance StrEncoding FileServerStatsData where
110116 _filesUploaded <- " filesUploaded=" *> strP <* A. endOfLine
111117 _filesExpired <- " filesExpired=" *> strP <* A. endOfLine <|> pure 0
112118 _filesDeleted <- " filesDeleted=" *> strP <* A. endOfLine
119+ _filesBlocked <- " filesBlocked=" *> strP <* A. endOfLine
113120 _filesCount <- " filesCount=" *> strP <* A. endOfLine <|> pure 0
114121 _filesSize <- " filesSize=" *> strP <* A. endOfLine <|> pure 0
115122 _filesDownloaded <- " filesDownloaded:" *> A. endOfLine *> strP <* A. endOfLine
116123 _fileDownloads <- " fileDownloads=" *> strP <* A. endOfLine
117124 _fileDownloadAcks <- " fileDownloadAcks=" *> strP <* A. endOfLine
118- pure FileServerStatsData {_fromTime, _filesCreated, _fileRecipients, _filesUploaded, _filesExpired, _filesDeleted, _filesDownloaded, _fileDownloads, _fileDownloadAcks, _filesCount, _filesSize}
125+ pure FileServerStatsData {_fromTime, _filesCreated, _fileRecipients, _filesUploaded, _filesExpired, _filesDeleted, _filesBlocked, _filesDownloaded, _fileDownloads, _fileDownloadAcks, _filesCount, _filesSize}
0 commit comments