1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-09 17:44:59 +09:00

GO-1084: Remove test code

This commit is contained in:
Sergey 2023-04-25 18:17:59 +02:00 committed by Mikhail Iudin
parent 700d65119e
commit 1a124282e8
No known key found for this signature in database
GPG key ID: FAAAA8BAABDFF1C0

View file

@ -8,7 +8,9 @@ import (
"github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"
"github.com/samber/lo"
"go.uber.org/zap"
"github.com/anytypeio/go-anytype-middleware/pb"
"github.com/anytypeio/go-anytype-middleware/util/conc"
)
@ -37,13 +39,45 @@ func (f *fileSync) SpaceStat(ctx context.Context, spaceId string) (ss SpaceStat,
if err != nil {
return
}
return SpaceStat{
newStats := SpaceStat{
SpaceId: spaceId,
FileCount: int(info.FilesCount),
CidsCount: int(info.CidsCount),
BytesUsage: int(info.UsageBytes),
BytesLimit: int(info.LimitBytes),
}, nil
}
f.spaceStatsLock.Lock()
prevStats, ok := f.spaceStats[spaceId]
if prevStats != newStats {
f.spaceStats[spaceId] = newStats
// Do not send event if it is first time we get stats
if ok {
f.sendSpaceUsageEvent(uint64(newStats.BytesUsage))
}
}
f.spaceStatsLock.Unlock()
return newStats, nil
}
func (f *fileSync) updateSpaceUsageInformation(spaceId string) {
if _, err := f.SpaceStat(context.Background(), spaceId); err != nil {
log.Warn("can't get space usage information", zap.String("spaceId", spaceId), zap.Error(err))
}
}
func (f *fileSync) sendSpaceUsageEvent(bytesUsage uint64) {
f.sendEvent(&pb.Event{
Messages: []*pb.EventMessage{
{
Value: &pb.EventMessageValueOfFileSpaceUsage{
FileSpaceUsage: &pb.EventFileSpaceUsage{
BytesUsage: bytesUsage,
},
},
},
},
})
}
func (f *fileSync) FileListStats(ctx context.Context, spaceID string, fileIDs []string) ([]FileStat, error) {