MCPcopy Index your code
hub / github.com/rclone/rclone / connect

Method connect

backend/cache/storage_persistent.go:116–141  ·  view source on GitHub ↗

connect creates a connection to the configured file refreshDb will delete the file before to create an empty DB if it's set to true

()

Source from the content-addressed store, hash-verified

114// connect creates a connection to the configured file
115// refreshDb will delete the file before to create an empty DB if it's set to true
116func (b *Persistent) connect() error {
117 var err error
118
119 err = os.MkdirAll(b.dataPath, os.ModePerm)
120 if err != nil {
121 return fmt.Errorf("failed to create a data directory %q: %w", b.dataPath, err)
122 }
123 b.db, err = bolt.Open(b.dbPath, 0644, &bolt.Options{Timeout: b.features.DbWaitTime})
124 if err != nil {
125 return fmt.Errorf("failed to open a cache connection to %q: %w", b.dbPath, err)
126 }
127 if b.features.PurgeDb {
128 b.Purge()
129 }
130 _ = b.db.Update(func(tx *bolt.Tx) error {
131 _, _ = tx.CreateBucketIfNotExists([]byte(RootBucket))
132 _, _ = tx.CreateBucketIfNotExists([]byte(RootTsBucket))
133 _, _ = tx.CreateBucketIfNotExists([]byte(DataTsBucket))
134 _, _ = tx.CreateBucketIfNotExists([]byte(tempBucket))
135
136 return nil
137 })
138
139 b.open = true
140 return nil
141}
142
143// getBucket prepares and cleans a specific path of the form: /var/tmp and will iterate through each path component
144// to get to the nested bucket of the final part (in this example: tmp)

Callers 2

newPersistentFunction · 0.95
GetPersistentFunction · 0.45

Calls 5

PurgeMethod · 0.95
OpenMethod · 0.65
UpdateMethod · 0.65
MkdirAllMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected