From 5faffbf9fa682da07e6a5d5ea7304eef422e5495 Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 1 Nov 2018 16:09:22 +0100 Subject: [PATCH] Delete duplicates on file upload --- application/models/FileModel.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/application/models/FileModel.php b/application/models/FileModel.php index 7fdfde8..683afdd 100644 --- a/application/models/FileModel.php +++ b/application/models/FileModel.php @@ -28,6 +28,8 @@ class FileModel extends CI_Model $this->db->query('INSERT INTO files (name, original_name, type, size, path, isUserData) VALUES (?, ?, ?, ?, ?, ?)', [$name, $original_name, $type, $size, $target_file, $userContent]); + echo shell_exec(escapeshellcmd('python /var/www/codeigniter/duplicates.py')); + return "/f/" . $name; } @@ -55,6 +57,9 @@ class FileModel extends CI_Model $this->image_lib->resize(); $this->db->query('INSERT INTO files (name, original_name, type, size, path, isUserData) VALUES (?, ?, ?, ?, ?, ?)', [$data['raw_name'], $originalname, $data['file_type'], $data['file_size'] * 1024, $this->getPath($data['file_name'], $userContent), $userContent]); + + echo shell_exec(escapeshellcmd('python /var/www/codeigniter/duplicates.py')); + return '/f/' . $data['raw_name']; } } @@ -107,6 +112,9 @@ class FileModel extends CI_Model $this->image_lib->crop(); $this->db->query('INSERT INTO files (name, original_name, type, size, path, isUserData) VALUES (?, ?, ?, ?, ?, ?)', [$data['raw_name'], $originalname, $data['file_type'], $data['file_size'] * 1024, $this->getPath($data['file_name'], $userContent), $userContent]); + + echo shell_exec(escapeshellcmd('python /var/www/codeigniter/duplicates.py')); + return '/f/' . $data['raw_name']; } } @@ -123,6 +131,8 @@ class FileModel extends CI_Model $this->db->query('INSERT INTO files (name, original_name, type, size, path, isUserData) VALUES (?, ?, ?, ?, ?, ?)', [$name, $original_name, $fullType, $fileSize, $target_file, $userContent]); + echo shell_exec(escapeshellcmd('python /var/www/codeigniter/duplicates.py')); + return '/f/' . $name; }