mirror of https://github.com/perkeep/perkeep.git
Merge "pkg/index: ignore unset msdos time when possible"
This commit is contained in:
commit
eb0024f164
|
@ -327,7 +327,7 @@ var corpusMergeFunc = map[string]func(c *Corpus, k, v []byte) error{
|
|||
"signerkeyid": (*Corpus).mergeSignerKeyIdRow,
|
||||
"claim": (*Corpus).mergeClaimRow,
|
||||
"fileinfo": (*Corpus).mergeFileInfoRow,
|
||||
"filetimes": (*Corpus).mergeFileTimesRow,
|
||||
keyFileTimes.name: (*Corpus).mergeFileTimesRow,
|
||||
"imagesize": (*Corpus).mergeImageSizeRow,
|
||||
"wholetofile": (*Corpus).mergeWholeToFileRow,
|
||||
"exifgps": (*Corpus).mergeEXIFGPSRow,
|
||||
|
@ -350,7 +350,7 @@ var slurpPrefixes = []string{
|
|||
"signerkeyid:",
|
||||
"claim|",
|
||||
"fileinfo|",
|
||||
"filetimes|",
|
||||
keyFileTimes.name + "|",
|
||||
"imagesize|",
|
||||
"wholetofile|",
|
||||
"exifgps|",
|
||||
|
|
|
@ -1229,7 +1229,7 @@ func (x *Index) GetFileInfo(ctx context.Context, fileRef blob.Ref) (camtypes.Fil
|
|||
return x.corpus.GetFileInfo(ctx, fileRef)
|
||||
}
|
||||
ikey := "fileinfo|" + fileRef.String()
|
||||
tkey := "filetimes|" + fileRef.String()
|
||||
tkey := keyFileTimes.name + "|" + fileRef.String()
|
||||
// TODO: switch this to use syncutil.Group
|
||||
wg := new(sync.WaitGroup)
|
||||
wg.Add(2)
|
||||
|
|
|
@ -50,6 +50,14 @@ import (
|
|||
"perkeep.org/pkg/schema"
|
||||
)
|
||||
|
||||
func init() {
|
||||
t, err := time.Parse(time.RFC3339, msdosEpoch)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("Cannot parse MSDOS epoch: %v", err))
|
||||
}
|
||||
msdosEpochTime = t
|
||||
}
|
||||
|
||||
type mutationMap struct {
|
||||
kv map[string]string // the keys and values we populate
|
||||
|
||||
|
@ -424,7 +432,12 @@ func readPrefixOrFile(prefix []byte, fetcher blob.Fetcher, b *schema.Blob, fn fu
|
|||
return err
|
||||
}
|
||||
|
||||
var exifDebug, _ = strconv.ParseBool(os.Getenv("CAMLI_DEBUG_IMAGES"))
|
||||
const msdosEpoch = "1980-01-01T00:00:00Z"
|
||||
|
||||
var (
|
||||
exifDebug, _ = strconv.ParseBool(os.Getenv("CAMLI_DEBUG_IMAGES"))
|
||||
msdosEpochTime time.Time
|
||||
)
|
||||
|
||||
// b: the parsed file schema blob
|
||||
// mm: keys to populate
|
||||
|
@ -506,7 +519,14 @@ func (ix *Index) populateFile(fetcher blob.Fetcher, b *schema.Blob, mm *mutation
|
|||
time3339s = types.Time3339(sortTimes[0]).String()
|
||||
case len(sortTimes) >= 2:
|
||||
oldest, newest := sortTimes[0], sortTimes[len(sortTimes)-1]
|
||||
time3339s = types.Time3339(oldest).String() + "," + types.Time3339(newest).String()
|
||||
// Common enough exception: unset creation time from an MSDOS
|
||||
// system (which is the default in zip files). So if we have
|
||||
// another time to use, just ignore the MSDOS epoch one.
|
||||
if oldest.After(msdosEpochTime) {
|
||||
time3339s = types.Time3339(oldest).String() + "," + types.Time3339(newest).String()
|
||||
} else {
|
||||
time3339s = types.Time3339(newest).String()
|
||||
}
|
||||
}
|
||||
|
||||
mm.Set(keyWholeToFileRef.Key(wholeRef, blobRef), "1")
|
||||
|
|
Loading…
Reference in New Issue