(restoreConfig *RestoreConfig)
| 87 | } |
| 88 | |
| 89 | func (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. |
no test coverage detected