summaryrefslogtreecommitdiff
path: root/inc/media.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/media.php')
-rw-r--r--inc/media.php20
1 files changed, 13 insertions, 7 deletions
diff --git a/inc/media.php b/inc/media.php
index ac65603f1..be55f8044 100644
--- a/inc/media.php
+++ b/inc/media.php
@@ -341,16 +341,18 @@ function _media_upload_action($data) {
*
* @author Andreas Gohr <andi@splitbrain.org>
* @author Michael Klier <chi@chimeric.de>
+ * @author Kate Arzamastseva <pshns@ukr.net>
*/
function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite, $move = 'move_uploaded_file') {
global $conf;
global $lang;
$old = @filemtime($fn);
- //
- if(!@file_exists(mediaFN($id, $old)) && @file_exists($fn)) {
+ $oldRev = getRevisions($id, -1, 1, 1024, true); // from changelog
+ $oldRev = (int)(empty($oldRev)?0:$oldRev[0]);
+ if(!@file_exists(mediaFN($id, $old)) && @file_exists($fn) && $old>=$oldRev) {
// add old revision to the attic if missing
- saveOldMediaRevision($id);
+ media_saveOldRevision($id);
}
// prepare directory
@@ -376,17 +378,21 @@ function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite, $move = 'mov
}
/**
- * moves the current version to the media_attic and returns its
- * revision date
+ * Moves the current version of media file to the media_attic
+ * directory
+ *
+ * @author Kate Arzamastseva <pshns@ukr.net>
+ * @param string $id
+ * @return int - revision date
*/
-function saveOldMediaRevision($id, $move = 'copy'){
+function media_saveOldRevision($id){
global $conf;
$oldf = mediaFN($id);
if(!@file_exists($oldf)) return '';
$date = filemtime($oldf);
$newf = mediaFN($id,$date);
io_makeFileDir($newf);
- if($move($oldf, $newf)) {
+ if(copy($oldf, $newf)) {
// Set the correct permission here.
// Always chmod media because they may be saved with different permissions than expected from the php umask.
// (Should normally chmod to $conf['fperm'] only if $conf['fperm'] is set.)