Skip to content

Commit

Permalink
fix nul date #8
Browse files Browse the repository at this point in the history
  • Loading branch information
laaqxdze1k committed Sep 1, 2023
1 parent d424579 commit 71a1a92
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions cmdduplicate/duplicate.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ func DuplicateCommand(ctx context.Context, ic *immich.ImmichClient, log *logger.
return ctx.Err()
default:
count++
if app.DateRange.InRange(*a.ExifInfo.DateTimeOriginal) {
if app.DateRange.InRange(a.ExifInfo.DateTimeOriginal) {
k := duplicateKey{
Date: *a.ExifInfo.DateTimeOriginal,
Date: a.ExifInfo.DateTimeOriginal,
Name: a.OriginalFileName,
}
l := duplicate[k]
Expand Down
6 changes: 3 additions & 3 deletions cmdmetadata/metadatacmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ func MetadataCommand(ctx context.Context, ic *immich.ImmichClient, log *logger.L
for _, a := range list {
ba := broken{a: a}

if (app.MissingDate) && a.ExifInfo.DateTimeOriginal == nil {
if (app.MissingDate) && a.ExifInfo.DateTimeOriginal.IsZero() {
ba.reason = append(ba.reason, "capture date not set")
}
if (app.MissingDate) && a.ExifInfo.DateTimeOriginal != nil && (a.ExifInfo.DateTimeOriginal.Year() < 1900 || a.ExifInfo.DateTimeOriginal.Compare(now) > 0) {
if (app.MissingDate) && (a.ExifInfo.DateTimeOriginal.Year() < 1900 || a.ExifInfo.DateTimeOriginal.Compare(now) > 0) {
ba.reason = append(ba.reason, "capture date invalid")
}

if app.MissingDateDespiteName {
dt := metadata.TakeTimeFromName(path.Base(a.OriginalPath))
if !dt.IsZero() {
if (a.ExifInfo.DateTimeOriginal != nil && (math.Abs(float64(dt.Sub(*a.ExifInfo.DateTimeOriginal))) > float64(24.0*time.Hour))) || a.ExifInfo.DateTimeOriginal == nil {
if a.ExifInfo.DateTimeOriginal.IsZero() || (math.Abs(float64(dt.Sub(a.ExifInfo.DateTimeOriginal))) > float64(24.0*time.Hour)) {
ba.reason = append(ba.reason, "capture date invalid, but the name contains a date")
ba.fixable = true
ba.SideCar.DateTaken = dt
Expand Down
6 changes: 3 additions & 3 deletions cmdupload/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ func (ai *AssetIndex) AddLocalAsset(la *assets.LocalAssetFile, ImmichID string)
OriginalFileName: strings.TrimSuffix(path.Base(la.Title), path.Ext(la.Title)),
ExifInfo: immich.ExifInfo{
FileSizeInByte: int(la.Size()),
DateTimeOriginal: &la.DateTaken,
Latitude: &la.Latitude,
Longitude: &la.Longitude,
DateTimeOriginal: la.DateTaken,
Latitude: la.Latitude,
Longitude: la.Longitude,
},
JustUploaded: true,
}
Expand Down
2 changes: 1 addition & 1 deletion cmdupload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ func (ai *AssetIndex) ShouldUpload(la *assets.LocalAssetFile) (*Advice, error) {

}
for _, sa = range l {
compareDate := dateTaken.Compare(*sa.ExifInfo.DateTimeOriginal)
compareDate := dateTaken.Compare(sa.ExifInfo.DateTimeOriginal)
compareSize := size - sa.ExifInfo.FileSizeInByte

switch {
Expand Down
18 changes: 9 additions & 9 deletions immich/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@ type Asset struct {
}

type ExifInfo struct {
Make string `json:"make"`
Model string `json:"model"`
ExifImageWidth int `json:"exifImageWidth"`
ExifImageHeight int `json:"exifImageHeight"`
FileSizeInByte int `json:"fileSizeInByte"`
Orientation string `json:"orientation"`
DateTimeOriginal *time.Time `json:"dateTimeOriginal"`
Make string `json:"make"`
Model string `json:"model"`
ExifImageWidth int `json:"exifImageWidth"`
ExifImageHeight int `json:"exifImageHeight"`
FileSizeInByte int `json:"fileSizeInByte"`
Orientation string `json:"orientation"`
DateTimeOriginal time.Time `json:"dateTimeOriginal,omitempty"`
// ModifyDate time.Time `json:"modifyDate"`
TimeZone string `json:"timeZone"`
// LensModel string `json:"lensModel"`
// FNumber float64 `json:"fNumber"`
// FocalLength float64 `json:"focalLength"`
// Iso int `json:"iso"`
// ExposureTime string `json:"exposureTime"`
Latitude *float64 `json:"latitude,omitempty"`
Longitude *float64 `json:"longitude,omitempty"`
Latitude float64 `json:"latitude,omitempty"`
Longitude float64 `json:"longitude,omitempty"`
// City string `json:"city"`
// State string `json:"state"`
// Country string `json:"country"`
Expand Down

0 comments on commit 71a1a92

Please sign in to comment.