Final implement of clamav gem

This commit is contained in:
Xavier J 2016-04-15 15:32:15 +02:00
parent 4099efd326
commit 900b377ae2
5 changed files with 37 additions and 16 deletions

View file

@ -5,20 +5,18 @@ class PiecesJustificativesService
dossier.types_de_piece_justificative.each do |type_de_pieces_justificatives|
unless params["piece_justificative_#{type_de_pieces_justificatives.id}"].nil?
# unless ClamavService.safe_io_data? params["piece_justificative_#{type_de_pieces_justificatives.id}"].path
#
# end
if ClamavService.safe_file? params["piece_justificative_#{type_de_pieces_justificatives.id}"].path
piece_justificative = PieceJustificative.new(content: params["piece_justificative_#{type_de_pieces_justificatives.id}"],
dossier: dossier,
type_de_piece_justificative: type_de_pieces_justificatives,
user: user)
piece_justificative = PieceJustificative.new(content: params["piece_justificative_#{type_de_pieces_justificatives.id}"],
dossier: dossier,
type_de_piece_justificative: type_de_pieces_justificatives,
user: user)
unless piece_justificative.save
errors << piece_justificative.errors.messages[:content][0]+" (#{piece_justificative.libelle})"+"<br>"
unless piece_justificative.save
errors << piece_justificative.errors.messages[:content][0]+" (#{piece_justificative.libelle})"+"<br>"
end
else
errors << params["piece_justificative_#{type_de_pieces_justificatives.id}"].original_filename+": <b>Virus détecté !!</b>"+"<br>"
end
end
end
errors