MCPcopy Create free account
hub / github.com/apecloud/myduckserver / executeRestore

Method executeRestore

pgserver/restore_handler.go:89–106  ·  view source on GitHub ↗
(restoreConfig *RestoreConfig)

Source from the content-addressed store, hash-verified

87}
88
89func (h *ConnectionHandler) executeRestore(restoreConfig *RestoreConfig) (string, error) {
90 provider := h.server.Provider
91 msg, err := restoreConfig.StorageConfig.DownloadFile(restoreConfig.RemoteFile, provider.DataDir(), restoreConfig.DbName+".db")
92 if err != nil {
93 return "", fmt.Errorf("failed to download file: %w", err)
94 }
95 dbFile := filepath.Join(provider.DataDir(), restoreConfig.DbName+".db")
96 // load dbFile as DirEntry
97 file, err := os.Stat(dbFile)
98 if err != nil {
99 return "", fmt.Errorf("failed to stat file: %w", err)
100 }
101 err = provider.AttachCatalog(file, false)
102 if err != nil {
103 return "", fmt.Errorf("failed to attach catalog: %w", err)
104 }
105 return msg, nil
106}
107
108// ExecuteRestore downloads the specified file from the remote storage and restores it to the specified local directory.
109// Note that this should only be called at startup, as this function does not attach the restored database to the catalog.

Callers 1

runMethod · 0.95

Calls 3

AttachCatalogMethod · 0.80
DataDirMethod · 0.65
DownloadFileMethod · 0.45

Tested by

no test coverage detected