adding decompress
This commit is contained in:
@@ -88,7 +88,7 @@ func (db *DB) UpdateFileData(filePath, basePath string, hash []byte) error {
|
||||
db.Err(err).Msg("Error updating the file base")
|
||||
return err
|
||||
} else {
|
||||
err := db.Update(&File{ID: file.ID, CurrentBase: basePath, Hash: hash})
|
||||
err := db.Update(&File{ID: file.ID, BaseFilePath: basePath, Hash: hash})
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -198,6 +198,18 @@ func (db *DB) FetchLastCommitOnBranch(branch string) (commitResult Commit, err e
|
||||
err = query.OrderBy("Number").Reverse().First(&commit) // Getting the last entry by number
|
||||
if err != nil {
|
||||
db.Err(err).Msgf("Failed to find last commit on branch: %s", branch)
|
||||
return commit, err
|
||||
}
|
||||
return commit, nil
|
||||
}
|
||||
|
||||
// NewCommit writes a new commit to the specified branch into the database
|
||||
func (db *DB) NewCommit(newCommit Commit, branch string) error {
|
||||
db.Info().Msgf("Writing new commit: %s on branch: %s", newCommit.Number, branch)
|
||||
err := db.Save(&newCommit)
|
||||
if err != nil {
|
||||
db.Err(err).Msg("failure to write commit to database")
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ type GVCInfo struct {
|
||||
|
||||
// Commit stores all the necessary information for a commit
|
||||
type Commit struct {
|
||||
CommitHash []byte `storm:"index,unique"` // The hash of the commit (generated by hashing commit author name, time, the previous commit, and more? TODO: Not sure what else)
|
||||
CommitHash []byte `storm:"id,index,unique"` // The hash of the commit (generated by hashing commit author name, time, the previous commit, and more? TODO: Not sure what else)
|
||||
TrackedFiles []File // All of the tracked files for this commit
|
||||
Date string
|
||||
Version string //User can tag a commit with a version number
|
||||
@@ -43,19 +43,19 @@ type CommitMeta struct {
|
||||
|
||||
// File represents a tracked file
|
||||
type File struct {
|
||||
ID int `storm:"id,increment"`
|
||||
Path string `storm:"index"`
|
||||
Name string
|
||||
//BkpLocation string //TODO: Needed?
|
||||
CurrentBase string
|
||||
Hash []byte `storm:"index,unique"` // with []byte can't use sha256.sum256 since that is [32]byte, so everything done manually.
|
||||
CreatedAt time.Time
|
||||
Unique string
|
||||
Version float64
|
||||
NoCompress bool // Whether or not to compress this file
|
||||
ID int `storm:"id,increment"`
|
||||
Path string `storm:"index"`
|
||||
BaseFilePath string // This stores the path to the tracked version of the file in the object database
|
||||
Name string
|
||||
//CurrentBase string
|
||||
Hash []byte `storm:"index,unique"` // with []byte can't use sha256.sum256 since that is [32]byte, so everything done manually.
|
||||
CreatedAt time.Time
|
||||
Unique string
|
||||
Version float64
|
||||
NoCompress bool // Whether or not to compress this file
|
||||
}
|
||||
|
||||
// CalculateHash creates a hash for the file
|
||||
// CalculateHash creates a hash for the file //Requires path
|
||||
func (f *File) CalculateHash() error {
|
||||
fileContents, err := ioutil.ReadFile(f.Path)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user