1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-11 18:20:33 +09:00

GO-1340: Add File.LimitReached event

This commit is contained in:
Sergey 2023-04-25 18:17:59 +02:00 committed by Mikhail Iudin
parent bb8e1033d7
commit 8b414b07a8
No known key found for this signature in database
GPG key ID: FAAAA8BAABDFF1C0
4 changed files with 4769 additions and 4292 deletions

View file

@ -16,7 +16,9 @@ import (
"github.com/samber/lo"
"go.uber.org/zap"
"github.com/anytypeio/go-anytype-middleware/core/event"
"github.com/anytypeio/go-anytype-middleware/core/filestorage/rpcstore"
"github.com/anytypeio/go-anytype-middleware/pb"
"github.com/anytypeio/go-anytype-middleware/pkg/lib/datastore"
"github.com/anytypeio/go-anytype-middleware/pkg/lib/localstore"
"github.com/anytypeio/go-anytype-middleware/pkg/lib/localstore/filestore"
@ -62,6 +64,7 @@ type fileSync struct {
removePingCh chan struct{}
dagService ipld.DAGService
fileStore filestore.FileStore
sendEvent func(event *pb.Event)
}
func (f *fileSync) Init(a *app.App) (err error) {
@ -71,6 +74,7 @@ func (f *fileSync) Init(a *app.App) (err error) {
f.fileStore = app.MustComponent[filestore.FileStore](a)
f.removePingCh = make(chan struct{})
f.uploadPingCh = make(chan struct{})
f.sendEvent = app.MustComponent[event.Sender](a).Send
return
}
@ -250,6 +254,18 @@ func (f *fileSync) uploadFile(ctx context.Context, spaceId, fileId string) (err
bytesLeft := stat.BytesLimit - stat.BytesUsage
if bytesToUpload > bytesLeft {
f.sendEvent(&pb.Event{
Messages: []*pb.EventMessage{
{
Value: &pb.EventMessageValueOfFileLimitReached{
FileLimitReached: &pb.EventFileLimitReached{
SpaceId: spaceId,
FileId: fileId,
},
},
},
},
})
return errReachedLimit
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -90,6 +90,8 @@ message Event {
Process.Done processDone = 103;
Status.Thread threadStatus = 110;
File.LimitReached fileLimitReached = 111;
}
}
@ -976,6 +978,13 @@ message Event {
}
}
}
message File {
message LimitReached {
string spaceId = 1;
string fileId = 2;
}
}
}
message ResponseEvent {