mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-08 05:47:07 +09:00
GO-4146 Fix some lint errors
This commit is contained in:
parent
4e380b5236
commit
35aeb0ae6c
12 changed files with 24 additions and 24 deletions
|
@ -132,11 +132,11 @@ func main() {
|
|||
if err != nil {
|
||||
log.Fatal("can't open objectStore info:", err)
|
||||
}
|
||||
defer f.Close()
|
||||
info := &model.ObjectInfo{}
|
||||
if err = jsonpb.Unmarshal(f, info); err != nil {
|
||||
log.Fatal("can't unmarshal objectStore info:", err)
|
||||
}
|
||||
defer f.Close()
|
||||
fmt.Println(pbtypes.Sprint(info))
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"sync"
|
||||
|
||||
"github.com/anyproto/any-sync/app"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/anyproto/anytype-heart/core/anytype"
|
||||
"github.com/anyproto/anytype-heart/core/anytype/config"
|
||||
|
@ -106,7 +107,10 @@ func (m *migration) setFinished(err error, notify bool) {
|
|||
|
||||
func (m *migration) cancelMigration() {
|
||||
m.cancel()
|
||||
_ = m.wait()
|
||||
err := m.wait()
|
||||
if err != nil {
|
||||
log.Warn("failed to wait for migration to finish", zap.Error(err))
|
||||
}
|
||||
}
|
||||
|
||||
func (m *migration) wait() error {
|
||||
|
|
|
@ -83,7 +83,7 @@ func (e *treeExporter) Export(ctx context.Context, path string, tree objecttree.
|
|||
data[0].Relations[i] = transform(r, e.anonymized, anonymize.Relation)
|
||||
}
|
||||
osData := pbtypes.Sprint(data[0].ToProto())
|
||||
er := os.WriteFile(localStorePath, []byte(osData), 0644)
|
||||
er := os.WriteFile(localStorePath, []byte(osData), 0600)
|
||||
if er != nil {
|
||||
e.log.Printf("localstore.json write error: %v", err)
|
||||
} else {
|
||||
|
@ -93,7 +93,7 @@ func (e *treeExporter) Export(ctx context.Context, path string, tree objecttree.
|
|||
e.log.Printf("no data in objectstore")
|
||||
}
|
||||
}
|
||||
err = os.WriteFile(logPath, logBuf.Bytes(), 0644)
|
||||
err = os.WriteFile(logPath, logBuf.Bytes(), 0600)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -345,7 +345,10 @@ func (s *space) migrationProfileObject(ctx context.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
extractedProfileExists, _ := s.Storage().HasTree(ctx, extractedProfileId)
|
||||
extractedProfileExists, err := s.Storage().HasTree(ctx, extractedProfileId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if extractedProfileExists {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -132,8 +132,8 @@ func (r *clientStorage) modifyState(ctx context.Context, isCreated bool) error {
|
|||
})
|
||||
_, err = r.clientColl.UpsertId(tx.Context(), clientDocumentKey, mod)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
rollErr := tx.Rollback()
|
||||
return errors.Join(err, rollErr)
|
||||
}
|
||||
return tx.Commit()
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ import (
|
|||
anystore "github.com/anyproto/any-store"
|
||||
"github.com/anyproto/any-sync/app"
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
"github.com/anyproto/any-sync/app/ocache"
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage"
|
||||
)
|
||||
|
||||
// nolint: unused
|
||||
var log = logger.NewNamed(spacestorage.CName)
|
||||
|
||||
func New(rootPath string) *storageService {
|
||||
|
@ -25,14 +25,13 @@ func New(rootPath string) *storageService {
|
|||
|
||||
type storageService struct {
|
||||
rootPath string
|
||||
cache ocache.OCache
|
||||
}
|
||||
|
||||
func (s *storageService) AllSpaceIds() (ids []string, err error) {
|
||||
var files []string
|
||||
fileInfo, err := os.ReadDir(s.rootPath)
|
||||
if err != nil {
|
||||
return files, fmt.Errorf("can't read datadir '%v': %v", s.rootPath, err)
|
||||
return files, fmt.Errorf("can't read datadir '%v': %w", s.rootPath, err)
|
||||
}
|
||||
for _, file := range fileInfo {
|
||||
if !strings.HasPrefix(file.Name(), ".") {
|
||||
|
|
|
@ -41,7 +41,6 @@ type migrator struct {
|
|||
newStorage storage.ClientStorage
|
||||
process process.Service
|
||||
path string
|
||||
oldPath string
|
||||
objectStorePath string
|
||||
finisher migratorfinisher.Service
|
||||
|
||||
|
@ -62,7 +61,6 @@ func New() app.ComponentRunnable {
|
|||
func (m *migrator) Init(a *app.App) (err error) {
|
||||
cfg := a.MustComponent("config").(pathProvider)
|
||||
m.path = cfg.GetNewSpaceStorePath()
|
||||
m.oldPath = cfg.GetOldSpaceStorePath()
|
||||
m.objectStorePath = filepath.Join(cfg.GetRepoPath(), "objectstore")
|
||||
m.oldStorage = app.MustComponent[oldstorage.ClientStorage](a)
|
||||
m.newStorage = app.MustComponent[storage.ClientStorage](a)
|
||||
|
|
|
@ -381,6 +381,7 @@ func (s *storageService) EstimateSize() (uint64, error) {
|
|||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
// nolint: gosec
|
||||
return uint64(stat.Size()), nil
|
||||
}
|
||||
|
||||
|
|
|
@ -39,11 +39,6 @@ type spaceStorage struct {
|
|||
header *spacesyncproto.RawSpaceHeaderWithId
|
||||
}
|
||||
|
||||
type oldTreeStorage interface {
|
||||
oldstorage.ChangesIterator
|
||||
oldstorage.TreeStorage
|
||||
}
|
||||
|
||||
func newSpaceStorage(s *storageService, spaceId string) (oldstorage.SpaceStorage, error) {
|
||||
ss := &spaceStorage{
|
||||
spaceId: spaceId,
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
|
||||
|
@ -205,14 +204,8 @@ func (t *treeStorage) AddRawChangesSetHeads(changes []*treechangeproto.RawTreeCh
|
|||
return nil
|
||||
}
|
||||
|
||||
var totalCalls atomic.Int32
|
||||
|
||||
func (t *treeStorage) GetRawChange(ctx context.Context, id string) (*treechangeproto.RawTreeChangeWithId, error) {
|
||||
ch, err := t.spaceStorage.TreeRoot(id)
|
||||
// totalCalls.Store(totalCalls.Load() + 1)
|
||||
// if totalCalls.Load()%10 == 0 {
|
||||
// fmt.Println("totalCalls", totalCalls.Load())
|
||||
// }
|
||||
if err != nil {
|
||||
return nil, replaceNoRowsErr(err, treestorage.ErrUnknownChange)
|
||||
}
|
||||
|
|
|
@ -16,6 +16,11 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
type oldTreeStorage interface {
|
||||
oldstorage.ChangesIterator
|
||||
oldstorage.TreeStorage
|
||||
}
|
||||
|
||||
func TestTreeStorage_Create(t *testing.T) {
|
||||
fx := newFixture(t)
|
||||
defer fx.finish(t)
|
||||
|
|
|
@ -57,6 +57,7 @@ func UnzipFolder(sourceZip, targetDir string) error {
|
|||
return err
|
||||
}
|
||||
for _, file := range r.File {
|
||||
// nolint: gosec
|
||||
extractedPath := filepath.Join(targetDir, file.Name)
|
||||
if file.FileInfo().IsDir() {
|
||||
if err := os.MkdirAll(extractedPath, 0700); err != nil {
|
||||
|
@ -82,6 +83,7 @@ func extractFile(file *zip.File, outputPath string) error {
|
|||
return err
|
||||
}
|
||||
defer outputFile.Close()
|
||||
// nolint: gosec
|
||||
_, err = io.Copy(outputFile, rc)
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue