feat: Enable indexing with tape as single source of truth after deletions

This commit is contained in:
Felicitas Pojtinger
2021-11-21 19:58:02 +01:00
parent a33c4cb588
commit d4c4eb41ef
5 changed files with 97 additions and 55 deletions
+30
View File
@@ -34,3 +34,33 @@ func DBHeaderToTarHeader(dbhdr *models.Header) (*tar.Header, error) {
return hdr, nil
}
func TarHeaderToDBHeader(record, block int64, tarhdr *tar.Header) (*models.Header, error) {
paxRecords, err := json.Marshal(tarhdr.PAXRecords)
if err != nil {
return nil, err
}
hdr := models.Header{
Record: record,
Block: block,
Typeflag: int64(tarhdr.Typeflag),
Name: tarhdr.Name,
Linkname: tarhdr.Linkname,
Size: tarhdr.Size,
Mode: tarhdr.Mode,
UID: int64(tarhdr.Uid),
Gid: int64(tarhdr.Gid),
Uname: tarhdr.Uname,
Gname: tarhdr.Gname,
Modtime: tarhdr.ModTime,
Accesstime: tarhdr.AccessTime,
Changetime: tarhdr.ChangeTime,
Devmajor: tarhdr.Devmajor,
Devminor: tarhdr.Devminor,
Paxrecords: string(paxRecords),
Format: int64(tarhdr.Format),
}
return &hdr, nil
}