forked from longhorn/backupstore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhead.go
More file actions
36 lines (29 loc) · 739 Bytes
/
Copy pathhead.go
File metadata and controls
36 lines (29 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package backupstore
import (
"fmt"
"time"
)
type ConfigMetadata struct {
ModificationTime time.Time
}
func GetConfigMetadata(url string) (*ConfigMetadata, error) {
driver, err := GetBackupStoreDriver(url)
if err != nil {
return nil, err
}
backupName, volumeName, _, err := DecodeBackupURL(url)
if err != nil {
return nil, err
}
var filePath string
if backupName != "" {
filePath = getBackupConfigPath(backupName, volumeName)
} else {
filePath = getVolumeFilePath(volumeName)
}
if !driver.FileExists(filePath) {
return &ConfigMetadata{}, fmt.Errorf("cannot find %v in backupstore", filePath)
}
modificationTime := driver.FileTime(filePath)
return &ConfigMetadata{ModificationTime: modificationTime}, nil
}