update script

This commit is contained in:
Pasha 2024-11-21 12:45:31 +03:00
parent a420869004
commit 6254aa585c

@ -19,6 +19,7 @@ const (
mongoURI = "mongodb://test:test@localhost:27024/?authSource=admin"
mongoDBName = "admin"
collectionName = "verification"
folder = "folder"
)
func main() {
@ -107,6 +108,7 @@ func getVerificationRecords(ctx context.Context, collection *mongo.Collection) (
// проверка на существования файла минио в монге по урлу
func checkContains(verifications []models.Verification, fileKey string) bool {
firstTry := func(verifications []models.Verification, fileKey string) bool {
fileURL := fmt.Sprintf("%s/%s/%s", minioEndpoint, bucketName, fileKey)
for _, verification := range verifications {
for _, file := range verification.Files {
@ -117,3 +119,25 @@ func checkContains(verifications []models.Verification, fileKey string) bool {
}
return false
}
secondTry := func(verifications []models.Verification, fileKey string) bool {
for _, verification := range verifications {
for _, file := range verification.Files {
fileURL := fmt.Sprintf("%s/%s/%s/%s/%s", minioEndpoint, bucketName, folder, verification.UserID, fileKey)
if file.Url == fileURL {
return true
}
}
}
return false
}
if firstTry(verifications, fileKey) {
return true
}
if secondTry(verifications, fileKey) {
return true
}
return false
}