PR Feedback

This commit is contained in:
Neil Macneale IV
2024-07-30 09:36:44 -07:00
parent becff737fd
commit 4e66009c2a
5 changed files with 14 additions and 7 deletions

View File

@@ -95,6 +95,10 @@ type DoltEnv struct {
UserPassConfig *creds.DoltCredsForPass
}
// IncompleteEnv returns a DoltEnv that is incomplete. There are cases where we want to know that the structure
// of and database is correct on disk, but don't want to actually load the database.
//
// Callers of this method should not expect the returned DoltEnv to be useful as a database for running queries.
func IncompleteEnv(FS filesys.Filesys) *DoltEnv {
return &DoltEnv{
Version: doltversion.Version,

View File

@@ -54,6 +54,8 @@ type MultiRepoEnv struct {
dialProvider dbfactory.GRPCDialProvider
}
// StorageMetadataMap is a map of table file and archive paths to their metadata. It is used to surface specific
// information about the storage of a database without loading the storage files themselves.
type StorageMetadataMap map[string]nbs.StorageMetadata
func (sms StorageMetadataMap) ArchiveFilesPresent() bool {
@@ -84,16 +86,17 @@ func GetMultiEnvStorageMetadata(dataDirFS filesys.Filesys) (StorageMetadataMap,
dir := filepath.Base(path)
newFs, er2 := dataDirFS.WithWorkingDir(dir)
if er2 != nil {
newFs, err := dataDirFS.WithWorkingDir(dir)
if err != nil {
return false
}
path, er2 = newFs.Abs("")
if er2 != nil {
path, err = newFs.Abs("")
if err != nil {
return false
}
envName := getRepoRootDir(path, string(os.PathSeparator))
// For an incomplete environment, the .Valid() check basically just checks if there is a .dolt directory.
falseEnv := IncompleteEnv(newFs)
if !falseEnv.Valid() {
return false

View File

@@ -85,7 +85,7 @@ func NewServer(args ServerArgs) (*Server, error) {
return nil, err
}
if storageMetadata.ArchiveFilesPresent() {
return nil, errors.New("archive files present")
return nil, errors.New("archive files present. Please run `dolt archive --revert` before running the server.")
}
s := new(Server)

View File

@@ -52,7 +52,7 @@ func UnArchive(ctx context.Context, cs chunks.ChunkStore, smd StorageMetadata, p
for id, ogcs := range oldgen {
if arc, ok := ogcs.(archiveChunkSource); ok {
orginTfId := revertMap[id]
exists, err := smd.LoseOldGenTableExists(orginTfId)
exists, err := smd.oldGenTableExists(orginTfId)
if err != nil {
return err
}

View File

@@ -68,7 +68,7 @@ func (sm *StorageMetadata) RevertMap() map[hash.Hash]hash.Hash {
return revertMap
}
func (sm *StorageMetadata) LoseOldGenTableExists(id hash.Hash) (bool, error) {
func (sm *StorageMetadata) oldGenTableExists(id hash.Hash) (bool, error) {
path := filepath.Join(sm.root, ".dolt", "noms", "oldgen", id.String())
_, err := os.Stat(path)
if err != nil {