🐛 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" />
|
||||
</component>
|
||||
<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$/pkg/internal/services/analyzer.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/analyzer.go" afterDir="false" />
|
||||
</list>
|
||||
@ -117,7 +117,6 @@
|
||||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value=":sparkles: Attachment has pool" />
|
||||
<MESSAGE value=":sparkles: Pool clean by lifecycle config" />
|
||||
<MESSAGE value=":recycle: Split mark and delete file" />
|
||||
<MESSAGE value=":bug: Fix migration issue on pools" />
|
||||
@ -142,7 +141,8 @@
|
||||
<MESSAGE value=":sparkles: Attachment API can edit metadata" />
|
||||
<MESSAGE value=":lock: Fix Attachment will contains GPS information" />
|
||||
<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 name="VgoProject">
|
||||
<settings-migrated>true</settings-migrated>
|
||||
|
@ -160,21 +160,20 @@ func AnalyzeAttachment(file models.Attachment) error {
|
||||
|
||||
// Removing location EXIF data
|
||||
et, err := exiftool.NewExiftool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error when intializing exiftool: %v", err)
|
||||
}
|
||||
defer et.Close()
|
||||
exif := et.ExtractMetadata(dst)
|
||||
for _, data := range exif {
|
||||
for k, _ := range data.Fields {
|
||||
if strings.HasPrefix(k, "GPS") {
|
||||
data.Clear(k)
|
||||
} else if lo.Contains(exifWhitelist, k) {
|
||||
file.Metadata["exif"].(map[string]any)[k] = data.Fields[k]
|
||||
if err == nil {
|
||||
defer et.Close()
|
||||
exif := et.ExtractMetadata(dst)
|
||||
for _, data := range exif {
|
||||
for k, _ := range data.Fields {
|
||||
if strings.HasPrefix(k, "GPS") {
|
||||
data.Clear(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":
|
||||
// Dealing with video
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
@ -202,21 +201,20 @@ func AnalyzeAttachment(file models.Attachment) error {
|
||||
|
||||
// Removing location EXIF data
|
||||
et, err := exiftool.NewExiftool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error when intializing exiftool: %v", err)
|
||||
}
|
||||
defer et.Close()
|
||||
exif := et.ExtractMetadata(dst)
|
||||
for _, data := range exif {
|
||||
for k, _ := range data.Fields {
|
||||
if strings.HasPrefix(k, "GPS") {
|
||||
data.Clear(k)
|
||||
} else if lo.Contains(exifWhitelist, k) {
|
||||
file.Metadata["exif"].(map[string]any)[k] = data.Fields[k]
|
||||
if err == nil {
|
||||
defer et.Close()
|
||||
exif := et.ExtractMetadata(dst)
|
||||
for _, data := range exif {
|
||||
for k, _ := range data.Fields {
|
||||
if strings.HasPrefix(k, "GPS") {
|
||||
data.Clear(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