🐛 Trying to prevent exiftool causing analyze failed
This commit is contained in:
parent
e123c82c2b
commit
cbe034a049
@ -4,7 +4,7 @@
|
|||||||
<option name="autoReloadType" value="ALL" />
|
<option name="autoReloadType" value="ALL" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="18dd0d68-b4b8-40db-9734-9119b5c848bd" name="更改" comment=":sparkles: Save EXIF into file metadata">
|
<list default="true" id="18dd0d68-b4b8-40db-9734-9119b5c848bd" name="更改" comment=":zap: Use exif whitelist to prevent produce garbage data">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/services/analyzer.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/analyzer.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/internal/services/analyzer.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/analyzer.go" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
@ -117,7 +117,6 @@
|
|||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<MESSAGE value=":sparkles: Attachment has pool" />
|
|
||||||
<MESSAGE value=":sparkles: Pool clean by lifecycle config" />
|
<MESSAGE value=":sparkles: Pool clean by lifecycle config" />
|
||||||
<MESSAGE value=":recycle: Split mark and delete file" />
|
<MESSAGE value=":recycle: Split mark and delete file" />
|
||||||
<MESSAGE value=":bug: Fix migration issue on pools" />
|
<MESSAGE value=":bug: Fix migration issue on pools" />
|
||||||
@ -142,7 +141,8 @@
|
|||||||
<MESSAGE value=":sparkles: Attachment API can edit metadata" />
|
<MESSAGE value=":sparkles: Attachment API can edit metadata" />
|
||||||
<MESSAGE value=":lock: Fix Attachment will contains GPS information" />
|
<MESSAGE value=":lock: Fix Attachment will contains GPS information" />
|
||||||
<MESSAGE value=":sparkles: Save EXIF into file metadata" />
|
<MESSAGE value=":sparkles: Save EXIF into file metadata" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Save EXIF into file metadata" />
|
<MESSAGE value=":zap: Use exif whitelist to prevent produce garbage data" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value=":zap: Use exif whitelist to prevent produce garbage data" />
|
||||||
</component>
|
</component>
|
||||||
<component name="VgoProject">
|
<component name="VgoProject">
|
||||||
<settings-migrated>true</settings-migrated>
|
<settings-migrated>true</settings-migrated>
|
||||||
|
@ -160,21 +160,20 @@ func AnalyzeAttachment(file models.Attachment) error {
|
|||||||
|
|
||||||
// Removing location EXIF data
|
// Removing location EXIF data
|
||||||
et, err := exiftool.NewExiftool()
|
et, err := exiftool.NewExiftool()
|
||||||
if err != nil {
|
if err == nil {
|
||||||
return fmt.Errorf("error when intializing exiftool: %v", err)
|
defer et.Close()
|
||||||
}
|
exif := et.ExtractMetadata(dst)
|
||||||
defer et.Close()
|
for _, data := range exif {
|
||||||
exif := et.ExtractMetadata(dst)
|
for k, _ := range data.Fields {
|
||||||
for _, data := range exif {
|
if strings.HasPrefix(k, "GPS") {
|
||||||
for k, _ := range data.Fields {
|
data.Clear(k)
|
||||||
if strings.HasPrefix(k, "GPS") {
|
} else if lo.Contains(exifWhitelist, k) {
|
||||||
data.Clear(k)
|
file.Metadata["exif"].(map[string]any)[k] = data.Fields[k]
|
||||||
} else if lo.Contains(exifWhitelist, k) {
|
}
|
||||||
file.Metadata["exif"].(map[string]any)[k] = data.Fields[k]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
et.WriteMetadata(exif)
|
||||||
}
|
}
|
||||||
et.WriteMetadata(exif)
|
|
||||||
case "video":
|
case "video":
|
||||||
// Dealing with video
|
// Dealing with video
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
@ -202,21 +201,20 @@ func AnalyzeAttachment(file models.Attachment) error {
|
|||||||
|
|
||||||
// Removing location EXIF data
|
// Removing location EXIF data
|
||||||
et, err := exiftool.NewExiftool()
|
et, err := exiftool.NewExiftool()
|
||||||
if err != nil {
|
if err == nil {
|
||||||
return fmt.Errorf("error when intializing exiftool: %v", err)
|
defer et.Close()
|
||||||
}
|
exif := et.ExtractMetadata(dst)
|
||||||
defer et.Close()
|
for _, data := range exif {
|
||||||
exif := et.ExtractMetadata(dst)
|
for k, _ := range data.Fields {
|
||||||
for _, data := range exif {
|
if strings.HasPrefix(k, "GPS") {
|
||||||
for k, _ := range data.Fields {
|
data.Clear(k)
|
||||||
if strings.HasPrefix(k, "GPS") {
|
} else if lo.Contains(exifWhitelist, k) {
|
||||||
data.Clear(k)
|
file.Metadata["exif"].(map[string]any)[k] = data.Fields[k]
|
||||||
} else if lo.Contains(exifWhitelist, k) {
|
}
|
||||||
file.Metadata["exif"].(map[string]any)[k] = data.Fields[k]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
et.WriteMetadata(exif)
|
||||||
}
|
}
|
||||||
et.WriteMetadata(exif)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user