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:
parent
bb8e1033d7
commit
8b414b07a8
4 changed files with 4769 additions and 4292 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
7977
docs/proto.md
7977
docs/proto.md
File diff suppressed because it is too large
Load diff
1059
pb/events.pb.go
1059
pb/events.pb.go
File diff suppressed because it is too large
Load diff
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue