mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-21 17:46:48 +00:00
Other: Update golangci-lint to v1.50.0
This commit is contained in:
7
internal/store/cache/disk.go
vendored
7
internal/store/cache/disk.go
vendored
@ -23,7 +23,6 @@ import (
|
||||
"crypto/rand"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
@ -64,7 +63,7 @@ func NewOnDiskCache(path string, cmp Compressor, opts Options) (Cache, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
file, err := ioutil.TempFile(path, "tmp")
|
||||
file, err := os.CreateTemp(path, "tmp")
|
||||
defer func() {
|
||||
file.Close() //nolint:errcheck,gosec
|
||||
os.Remove(file.Name()) //nolint:errcheck,gosec
|
||||
@ -210,7 +209,7 @@ func (c *onDiskCache) readFile(path string) ([]byte, error) {
|
||||
// Wait before reading in case the file is currently being written.
|
||||
c.pending.wait(path)
|
||||
|
||||
return ioutil.ReadFile(filepath.Clean(path))
|
||||
return os.ReadFile(filepath.Clean(path))
|
||||
}
|
||||
|
||||
func (c *onDiskCache) writeFile(path string, b []byte) error {
|
||||
@ -235,7 +234,7 @@ func (c *onDiskCache) writeFile(path string, b []byte) error {
|
||||
defer c.update()
|
||||
|
||||
// NOTE(GODT-1158): What happens when this fails? Should be fixed eventually.
|
||||
return ioutil.WriteFile(filepath.Clean(path), b, 0o600)
|
||||
return os.WriteFile(filepath.Clean(path), b, 0o600)
|
||||
}
|
||||
|
||||
func (c *onDiskCache) hasSpace(size int) bool {
|
||||
|
||||
@ -20,7 +20,6 @@ package store
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
@ -162,7 +161,7 @@ func initMocks(tb testing.TB) (*mocksForStore, func()) {
|
||||
mocks.panicHandler.EXPECT().HandlePanic().AnyTimes()
|
||||
|
||||
var err error
|
||||
mocks.tmpDir, err = ioutil.TempDir("", "store-test")
|
||||
mocks.tmpDir, err = os.MkdirTemp("", "store-test")
|
||||
require.NoError(tb, err)
|
||||
|
||||
cacheFile := filepath.Join(mocks.tmpDir, "cache.json")
|
||||
|
||||
@ -21,7 +21,6 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/mail"
|
||||
"net/textproto"
|
||||
"strings"
|
||||
@ -126,7 +125,7 @@ func encryptDraft(kr *crypto.KeyRing, message *pmapi.Message, attachments []*dra
|
||||
|
||||
for _, att := range attachments {
|
||||
attachment := att.attachment
|
||||
attachmentBody, err := ioutil.ReadAll(att.reader)
|
||||
attachmentBody, err := io.ReadAll(att.reader)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to read attachment")
|
||||
}
|
||||
@ -158,7 +157,7 @@ func (store *Store) checkDraftTotalSize(message *pmapi.Message, attachments []*d
|
||||
|
||||
var attSize int64
|
||||
for _, att := range attachments {
|
||||
b, err := ioutil.ReadAll(att.encReader)
|
||||
b, err := io.ReadAll(att.encReader)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@ -111,13 +111,13 @@ func (store *Store) isSynced(countsOnAPI []*pmapi.MessagesCount) (bool, error) {
|
||||
// All Mail mailbox contains all messages, so we download all meta data needed
|
||||
// to generate any address/mailbox IMAP UIDs.
|
||||
// Sync state can be in three states:
|
||||
// * Nothing in database. For example when user logs in for the first time.
|
||||
// `triggerSync` will start full sync.
|
||||
// * Database has syncIDRangesKey and syncIDsToBeDeletedKey keys with data.
|
||||
// Sync is in progress or was interrupted. In later case when, `triggerSync`
|
||||
// will continue where it left off.
|
||||
// * Database has only syncStateKey with time when database was last synced.
|
||||
// `triggerSync` will reset it and start full sync again.
|
||||
// - Nothing in database. For example when user logs in for the first time.
|
||||
// `triggerSync` will start full sync.
|
||||
// - Database has syncIDRangesKey and syncIDsToBeDeletedKey keys with data.
|
||||
// Sync is in progress or was interrupted. In later case when, `triggerSync`
|
||||
// will continue where it left off.
|
||||
// - Database has only syncStateKey with time when database was last synced.
|
||||
// `triggerSync` will reset it and start full sync again.
|
||||
func (store *Store) triggerSync() {
|
||||
syncState := store.loadSyncState()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user