Skip to content

Commit

Permalink
Merge pull request #96 from Opetushallitus/OY-4829_chunkataan_bucketa…
Browse files Browse the repository at this point in the history
…v_pyynnot

OY-4829 chunkataan bucketav pyynnot
  • Loading branch information
jkorri authored May 23, 2024
2 parents cd3ed40 + dcc89ee commit 4f21bf3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/liiteri/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,14 @@
:header-params [{x-real-ip :- s/Str nil}
{user-agent :- s/Str nil}]
:query-params [{origin-system :- (api/describe (s/maybe s/Str) "Origin system - for example Ataru - optional") "tuntematon"}
{origin-reference :- (api/describe (s/maybe s/Str) "Origin reference - for example Application key - optional") "tuntematon"}]
{origin-reference :- (api/describe (s/maybe s/Str) "Origin reference - for example Application key - optional") "tuntematon"}
{refinalize :- (api/describe (s/maybe s/Bool) "Refinalize - run finalization even if file already finalized - optional") "tuntematon"}]
:body-params [keys :- [s/Str]]
(check-authorization! session)
(when (> (count keys) 0)
(let [metadata (file-metadata-store/get-metadata keys {:connection db})]
(file-metadata-store/finalize-files keys origin-system origin-reference {:connection db})
(virus-scan/request-file-scan virus-scan (filter (fn [item] (not (:final item))) metadata))
(virus-scan/request-file-scan virus-scan (filter (fn [item] (or (true? refinalize) (not (:final item)))) metadata))
(doseq [{key :key} metadata]
(audit-log/log audit-logger
(audit-log/user session x-real-ip user-agent)
Expand Down
19 changes: 10 additions & 9 deletions src/liiteri/virus_scan.clj
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,16 @@
(when (not-empty metadata)
(doseq [file metadata]
(log/info (str "Requesting file scan for " (:key file) ", to bucket " (:s3-bucket this))))
(.sendMessage (:sqs-request-scan-client this) (:request-queue-url this)
(json/generate-string {:objects
(map (fn [file]
{:bucket (:s3-bucket this)
:key (:key file)
:custom_data (json/generate-string {:start-time (System/currentTimeMillis)
:filename (:filename file)
:content-type (:content-type file)})})
metadata)})))))
(doseq [metadatapart (partition 10 10 [] metadata)] ; BucketAV hyväksyy maksimissaan 10 tiedostoa kerrallaan
(.sendMessage (:sqs-request-scan-client this) (:request-queue-url this)
(json/generate-string {:objects
(map (fn [file]
{:bucket (:s3-bucket this)
:key (:key file)
:custom_data (json/generate-string {:start-time (System/currentTimeMillis)
:filename (:filename file)
:content-type (:content-type file)})})
metadatapart)}))))))

(defn new-scanner []
(map->VirusScanner {}))

0 comments on commit 4f21bf3

Please sign in to comment.