diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/ajax/upload.php | 2 | ||||
-rw-r--r-- | apps/files/js/filelist.js | 4 | ||||
-rw-r--r-- | apps/files/js/files.js | 7 | ||||
-rw-r--r-- | apps/files/l10n/nl.php | 1 | ||||
-rw-r--r-- | apps/files/l10n/pl.php | 2 | ||||
-rw-r--r-- | apps/files_external/lib/amazons3.php | 5 | ||||
-rw-r--r-- | apps/files_external/lib/sftp.php | 4 | ||||
-rw-r--r-- | apps/files_external/lib/streamwrapper.php | 4 | ||||
-rw-r--r-- | apps/files_external/lib/swift.php | 4 | ||||
-rw-r--r-- | apps/files_external/lib/webdav.php | 2 | ||||
-rw-r--r-- | apps/files_trashbin/ajax/delete.php | 51 | ||||
-rw-r--r-- | apps/files_trashbin/ajax/undelete.php | 6 | ||||
-rw-r--r-- | apps/files_trashbin/index.php | 3 | ||||
-rw-r--r-- | apps/files_trashbin/js/trash.js | 48 | ||||
-rw-r--r-- | apps/files_trashbin/l10n/uk.php | 9 | ||||
-rw-r--r-- | apps/files_trashbin/templates/index.php | 7 | ||||
-rw-r--r-- | apps/files_trashbin/templates/part.list.php | 6 | ||||
-rw-r--r-- | apps/files_versions/appinfo/app.php | 2 | ||||
-rw-r--r-- | apps/files_versions/js/versions.js | 10 | ||||
-rw-r--r-- | apps/files_versions/l10n/uk.php | 8 | ||||
-rw-r--r-- | apps/files_versions/lib/hooks.php | 25 | ||||
-rw-r--r-- | apps/files_versions/lib/versions.php | 63 |
22 files changed, 156 insertions, 117 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index 07977f5ddf1..9031c729eff 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -48,7 +48,7 @@ $totalSize = 0; foreach ($files['size'] as $size) { $totalSize += $size; } -if ($totalSize > \OC\Files\Filesystem::free_space($dir)) { +if ($totalSize > $maxUploadFilesize) { OCP\JSON::error(array('data' => array('message' => $l->t('Not enough storage available'), 'uploadMaxFilesize' => $maxUploadFilesize, 'maxHumanFilesize' => $maxHumanFilesize))); diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index cc107656da8..0bf1f79ab77 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -315,8 +315,8 @@ var FileList={ do_delete:function(files){ if(files.substr){ files=[files]; - } - for (var i in files) { + } + for (var i=0; i<files.length; i++) { var deleteAction = $('tr').filterAttr('data-file',files[i]).children("td.date").children(".action.delete"); var oldHTML = deleteAction[0].outerHTML; var newHTML = '<img class="move2trash" data-action="Delete" title="'+t('files', 'perform delete operation')+'" src="'+ OC.imagePath('core', 'loading.gif') +'"></a>'; diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 918182162d4..8327460cca6 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -162,9 +162,10 @@ $(document).ready(function() { var tr=$('tr').filterAttr('data-file',filename); var renaming=tr.data('renaming'); if(!renaming && !FileList.isLoading(filename)){ - var mime=$(this).parent().parent().data('mime'); - var type=$(this).parent().parent().data('type'); - var permissions = $(this).parent().parent().data('permissions'); + FileActions.currentFile = $(this).parent(); + var mime=FileActions.getCurrentMimeType(); + var type=FileActions.getCurrentType(); + var permissions = FileActions.getCurrentPermissions(); var action=FileActions.getDefault(mime,type, permissions); if(action){ event.preventDefault(); diff --git a/apps/files/l10n/nl.php b/apps/files/l10n/nl.php index 381325d113c..a92ec933b22 100644 --- a/apps/files/l10n/nl.php +++ b/apps/files/l10n/nl.php @@ -60,6 +60,7 @@ "Text file" => "Tekstbestand", "Folder" => "Map", "From link" => "Vanaf link", +"Deleted files" => "Verwijderde bestanden", "Cancel upload" => "Upload afbreken", "Nothing in here. Upload something!" => "Er bevindt zich hier niets. Upload een bestand!", "Download" => "Download", diff --git a/apps/files/l10n/pl.php b/apps/files/l10n/pl.php index 83091bad18c..d68a871a7d7 100644 --- a/apps/files/l10n/pl.php +++ b/apps/files/l10n/pl.php @@ -10,6 +10,7 @@ "No file was uploaded" => "Nie przesłano żadnego pliku", "Missing a temporary folder" => "Brak katalogu tymczasowego", "Failed to write to disk" => "Błąd zapisu na dysk", +"Not enough storage available" => "Za mało miejsca", "Invalid directory." => "Zła ścieżka.", "Files" => "Pliki", "Delete" => "Usuwa element", @@ -54,6 +55,7 @@ "Text file" => "Plik tekstowy", "Folder" => "Katalog", "From link" => "Z linku", +"Deleted files" => "Pliki usnięte", "Cancel upload" => "Przestań wysyłać", "Nothing in here. Upload something!" => "Brak zawartości. Proszę wysłać pliki!", "Download" => "Pobiera element", diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php index 494885a1dd3..37e53a3a670 100644 --- a/apps/files_external/lib/amazons3.php +++ b/apps/files_external/lib/amazons3.php @@ -229,11 +229,6 @@ class AmazonS3 extends \OC\Files\Storage\Common { return false; } - public function free_space($path) { - // Infinite? - return false; - } - public function touch($path, $mtime = null) { if (is_null($mtime)) { $mtime = time(); diff --git a/apps/files_external/lib/sftp.php b/apps/files_external/lib/sftp.php index 3527f50ec98..785eb7dfc42 100644 --- a/apps/files_external/lib/sftp.php +++ b/apps/files_external/lib/sftp.php @@ -242,10 +242,6 @@ class SFTP extends \OC\Files\Storage\Common { } } - public function free_space($path) { - return -1; - } - public function touch($path, $mtime=null) { try { if (!is_null($mtime)) return false; diff --git a/apps/files_external/lib/streamwrapper.php b/apps/files_external/lib/streamwrapper.php index a631e7ce06a..4685877f26b 100644 --- a/apps/files_external/lib/streamwrapper.php +++ b/apps/files_external/lib/streamwrapper.php @@ -76,10 +76,6 @@ abstract class StreamWrapper extends \OC\Files\Storage\Common{ return fopen($this->constructUrl($path), $mode); } - public function free_space($path) { - return 0; - } - public function touch($path, $mtime=null) { $this->init(); if(is_null($mtime)) { diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php index 0fd6fa143b8..a00316c1f84 100644 --- a/apps/files_external/lib/swift.php +++ b/apps/files_external/lib/swift.php @@ -478,10 +478,6 @@ class SWIFT extends \OC\Files\Storage\Common{ } } - public function free_space($path) { - return 1024*1024*1024*8; - } - public function touch($path, $mtime=null) { $this->init(); $obj=$this->getObject($path); diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index 039a07b1ef2..91cc22779e6 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -222,7 +222,7 @@ class DAV extends \OC\Files\Storage\Common{ return 0; } } catch(\Exception $e) { - return 0; + return \OC\Files\FREE_SPACE_UNKNOWN; } } diff --git a/apps/files_trashbin/ajax/delete.php b/apps/files_trashbin/ajax/delete.php index f41482bef55..34f35c39ccb 100644 --- a/apps/files_trashbin/ajax/delete.php +++ b/apps/files_trashbin/ajax/delete.php @@ -3,24 +3,43 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); -$file = $_REQUEST['file']; +$files = $_POST['files']; +$dirlisting = $_POST['dirlisting']; +$list = json_decode($files); -$path_parts = pathinfo($file); -if ($path_parts['dirname'] == '.') { - $delimiter = strrpos($file, '.d'); - $filename = substr($file, 0, $delimiter); - $timestamp = substr($file, $delimiter+2); -} else { - $filename = $file; - $timestamp = null; -} +$error = array(); +$success = array(); -OCA\Files_Trashbin\Trashbin::delete($filename, $timestamp); +$i = 0; +foreach ($list as $file) { + if ( $dirlisting=='0') { + $delimiter = strrpos($file, '.d'); + $filename = substr($file, 0, $delimiter); + $timestamp = substr($file, $delimiter+2); + } else { + $filename = $file; + $timestamp = null; + } + + OCA\Files_Trashbin\Trashbin::delete($filename, $timestamp); + if (!OCA\Files_Trashbin\Trashbin::file_exists($filename, $timestamp)) { + $success[$i]['filename'] = $file; + $success[$i]['timestamp'] = $timestamp; + $i++; + } else { + $error[] = $filename; + } +} -if (!OCA\Files_Trashbin\Trashbin::file_exists($filename)) { - OCP\JSON::success(array("data" => array("filename" => $file))); -} else { +if ( $error ) { + $filelist = ''; + foreach ( $error as $e ) { + $filelist .= $e.', '; + } $l = OC_L10N::get('files_trashbin'); - OCP\JSON::error(array("data" => array("message" => $l->t("Couldn't delete %s permanently", array($file))))); + $message = $l->t("Couldn't delete %s permanently", array(rtrim($filelist, ', '))); + OCP\JSON::error(array("data" => array("message" => $message, + "success" => $success, "error" => $error))); +} else { + OCP\JSON::success(array("data" => array("success" => $success))); } - diff --git a/apps/files_trashbin/ajax/undelete.php b/apps/files_trashbin/ajax/undelete.php index 6320c1d0827..93f2aaf1fa2 100644 --- a/apps/files_trashbin/ajax/undelete.php +++ b/apps/files_trashbin/ajax/undelete.php @@ -3,9 +3,9 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); -$files = $_REQUEST['files']; -$dirlisting = $_REQUEST['dirlisting']; -$list = explode(';', $files); +$files = $_POST['files']; +$dirlisting = $_POST['dirlisting']; +$list = json_decode($files); $error = array(); $success = array(); diff --git a/apps/files_trashbin/index.php b/apps/files_trashbin/index.php index d575c75f1a3..2276fee2f81 100644 --- a/apps/files_trashbin/index.php +++ b/apps/files_trashbin/index.php @@ -16,6 +16,7 @@ OCP\Util::addScript('files', 'filelist'); $dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : ''; +$result = array(); if ($dir) { $dirlisting = true;
$fullpath = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath($dir); @@ -36,7 +37,7 @@ if ($dir) { ); }
} - closedir($fullpath); + closedir($dirContent); } else { $dirlisting = false; diff --git a/apps/files_trashbin/js/trash.js b/apps/files_trashbin/js/trash.js index 6c810e4c2bd..208cc88f0fd 100644 --- a/apps/files_trashbin/js/trash.js +++ b/apps/files_trashbin/js/trash.js @@ -6,9 +6,10 @@ $(document).ready(function() { var tr=$('tr').filterAttr('data-file', filename); var spinner = '<img class="move2trash" title="'+t('files_trashbin', 'perform restore operation')+'" src="'+ OC.imagePath('core', 'loader.gif') +'"></a>'; var undeleteAction = $('tr').filterAttr('data-file',filename).children("td.date"); + var files = tr.attr('data-file'); undeleteAction[0].innerHTML = undeleteAction[0].innerHTML+spinner; $.post(OC.filePath('files_trashbin','ajax','undelete.php'), - {files:tr.attr('data-file'), dirlisting:tr.attr('data-dirlisting') }, + {files:JSON.stringify([files]), dirlisting:tr.attr('data-dirlisting') }, function(result){ for (var i = 0; i < result.data.success.length; i++) { var row = document.getElementById(result.data.success[i].filename); @@ -31,16 +32,17 @@ $(document).ready(function() { var deleteAction = $('tr').filterAttr('data-file',filename).children("td.date").children(".action.delete"); var oldHTML = deleteAction[0].outerHTML; var newHTML = '<img class="move2trash" data-action="Delete" title="'+t('files', 'delete file permanently')+'" src="'+ OC.imagePath('core', 'loading.gif') +'"></a>'; + var files = tr.attr('data-file'); deleteAction[0].outerHTML = newHTML; $.post(OC.filePath('files_trashbin','ajax','delete.php'), - {file:tr.attr('data-file') }, + {files:JSON.stringify([files]), dirlisting:tr.attr('data-dirlisting') }, function(result){ - if ( result.status == 'success' ) { - var row = document.getElementById(result.data.filename); + for (var i = 0; i < result.data.success.length; i++) { + var row = document.getElementById(result.data.success[i].filename); row.parentNode.removeChild(row); - } else { - deleteAction[0].outerHTML = oldHTML; + } + if (result.status != 'success') { OC.dialogs.alert(result.data.message, 'Error'); } }); @@ -88,15 +90,15 @@ $(document).ready(function() { } } processSelection(); - }); + }); $('.undelete').click('click',function(event) { var spinner = '<img class="move2trash" title="'+t('files_trashbin', 'perform restore operation')+'" src="'+ OC.imagePath('core', 'loader.gif') +'"></a>'; var files=getSelectedFiles('file'); - var fileslist=files.join(';'); + var fileslist = JSON.stringify(files); var dirlisting=getSelectedFiles('dirlisting')[0]; - for (var i in files) { + for (var i=0; i<files.length; i++) { var undeleteAction = $('tr').filterAttr('data-file',files[i]).children("td.date"); undeleteAction[0].innerHTML = undeleteAction[0].innerHTML+spinner; } @@ -111,9 +113,33 @@ $(document).ready(function() { if (result.status != 'success') { OC.dialogs.alert(result.data.message, 'Error'); } - }); + }); + }); + + $('.delete').click('click',function(event) { + console.log("delete selected"); + var spinner = '<img class="move2trash" title="'+t('files_trashbin', 'Delete permanently')+'" src="'+ OC.imagePath('core', 'loading.gif') +'"></a>'; + var files=getSelectedFiles('file'); + var fileslist = JSON.stringify(files); + var dirlisting=getSelectedFiles('dirlisting')[0]; + + for (var i=0; i<files.length; i++) { + var deleteAction = $('tr').filterAttr('data-file',files[i]).children("td.date"); + deleteAction[0].innerHTML = deleteAction[0].innerHTML+spinner; + } + + $.post(OC.filePath('files_trashbin','ajax','delete.php'), + {files:fileslist, dirlisting:dirlisting}, + function(result){ + for (var i = 0; i < result.data.success.length; i++) { + var row = document.getElementById(result.data.success[i].filename); + row.parentNode.removeChild(row); + } + if (result.status != 'success') { + OC.dialogs.alert(result.data.message, 'Error'); + } + }); }); - }); diff --git a/apps/files_trashbin/l10n/uk.php b/apps/files_trashbin/l10n/uk.php index 14c6931255a..06474d9b2cd 100644 --- a/apps/files_trashbin/l10n/uk.php +++ b/apps/files_trashbin/l10n/uk.php @@ -1,7 +1,14 @@ <?php $TRANSLATIONS = array( +"Couldn't delete %s permanently" => "Неможливо видалити %s назавжди", +"Couldn't restore %s" => "Неможливо відновити %s", +"perform restore operation" => "виконати операцію відновлення", +"delete file permanently" => "видалити файл назавжди", "Name" => "Ім'я", +"Deleted" => "Видалено", "1 folder" => "1 папка", "{count} folders" => "{count} папок", "1 file" => "1 файл", -"{count} files" => "{count} файлів" +"{count} files" => "{count} файлів", +"Nothing in here. Your trash bin is empty!" => "Нічого немає. Ваший кошик для сміття пустий!", +"Restore" => "Відновити" ); diff --git a/apps/files_trashbin/templates/index.php b/apps/files_trashbin/templates/index.php index b62ca0af00c..aaeeb5c6f6e 100644 --- a/apps/files_trashbin/templates/index.php +++ b/apps/files_trashbin/templates/index.php @@ -25,6 +25,13 @@ </th> <th id="headerDate"> <span id="modified"><?php echo $l->t( 'Deleted' ); ?></span> + <span class="selectedActions"> + <a href="" class="delete"> + <?php echo $l->t('Delete')?> + <img class="svg" alt="<?php echo $l->t('Delete')?>" + src="<?php echo OCP\image_path("core", "actions/delete.svg"); ?>" /> + </a> + </span> </th> </tr> </thead> diff --git a/apps/files_trashbin/templates/part.list.php b/apps/files_trashbin/templates/part.list.php index fe8a71f44e6..2de0d7ee91a 100644 --- a/apps/files_trashbin/templates/part.list.php +++ b/apps/files_trashbin/templates/part.list.php @@ -1,12 +1,8 @@ <input type="hidden" id="disableSharing" data-status="<?php echo $_['disableSharing']; ?>"> <?php foreach($_['files'] as $file): - $simple_file_size = OCP\simple_file_size($file['size']); - // the bigger the file, the darker the shade of grey; megabytes*2 - $simple_size_color = intval(200-$file['size']/(1024*1024)*2); - if($simple_size_color<0) $simple_size_color = 0; $relative_deleted_date = OCP\relative_modified_date($file['timestamp']); // the older the file, the brighter the shade of grey; days*14 - $relative_date_color = round((time()-$file['mtime'])/60/60/24*14); + $relative_date_color = round((time()-$file['date'])/60/60/24*14); if($relative_date_color>200) $relative_date_color = 200; $name = str_replace('+', '%20', urlencode($file['name'])); $name = str_replace('%2F', '/', $name); diff --git a/apps/files_versions/appinfo/app.php b/apps/files_versions/appinfo/app.php index 9e3e81c580a..8e0356ada20 100644 --- a/apps/files_versions/appinfo/app.php +++ b/apps/files_versions/appinfo/app.php @@ -11,5 +11,5 @@ OCP\Util::addscript('files_versions', 'versions'); // Listen to write signals OCP\Util::connectHook('OC_Filesystem', 'write', "OCA\Files_Versions\Hooks", "write_hook"); // Listen to delete and rename signals -OCP\Util::connectHook('OC_Filesystem', 'post-delete', "OCA\Files_Versions\Hooks", "remove_hook"); +OCP\Util::connectHook('OC_Filesystem', 'post_delete', "OCA\Files_Versions\Hooks", "remove_hook"); OCP\Util::connectHook('OC_Filesystem', 'rename', "OCA\Files_Versions\Hooks", "rename_hook"); diff --git a/apps/files_versions/js/versions.js b/apps/files_versions/js/versions.js index b9c54689813..dec222eefce 100644 --- a/apps/files_versions/js/versions.js +++ b/apps/files_versions/js/versions.js @@ -41,6 +41,10 @@ $(document).ready(function(){ } }); +function goToVersionPage(url){ + window.location(url); +} + function createVersionsDropdown(filename, files) { var historyUrl = OC.linkTo('files_versions', 'history.php') + '?path='+encodeURIComponent( $( '#dir' ).val() ).replace( /%2F/g, '/' )+'/'+encodeURIComponent( filename ); @@ -51,7 +55,7 @@ function createVersionsDropdown(filename, files) { html += '<option value=""></option>'; html += '</select>'; html += '</div>'; - html += '<input type="button" value="All versions..." onclick="window.location=\''+historyUrl+'\'" name="makelink" id="makelink" />'; + html += '<input type="button" value="All versions..." name="makelink" id="makelink" />'; html += '<input id="link" style="display:none; width:90%;" />'; if (filename) { @@ -60,6 +64,10 @@ function createVersionsDropdown(filename, files) { } else { $(html).appendTo($('thead .share')); } + + $("#makelink").click(function() { + goToVersionPage(historyUrl); + }); $.ajax({ type: 'GET', diff --git a/apps/files_versions/l10n/uk.php b/apps/files_versions/l10n/uk.php index 49acda81079..861523bf6a4 100644 --- a/apps/files_versions/l10n/uk.php +++ b/apps/files_versions/l10n/uk.php @@ -1,5 +1,13 @@ <?php $TRANSLATIONS = array( +"Could not revert: %s" => "Не вдалося відновити: %s", +"success" => "успішно", +"File %s was reverted to version %s" => "Файл %s був відновлений до версії %s", +"failure" => "неуспішно", +"File %s could not be reverted to version %s" => "Файл %s не може бути відновлений до версії %s", +"No old versions available" => "Старі версії недоступні", +"No path specified" => "Шлях не вказаний", "History" => "Історія", +"Revert a file to a previous version by clicking on its revert button" => "Відновити файл на попередню версію, натиснувши на кнопку Відновити", "Files Versioning" => "Версії файлів", "Enable" => "Включити" ); diff --git a/apps/files_versions/lib/hooks.php b/apps/files_versions/lib/hooks.php index dc02c605c44..6c87eba423d 100644 --- a/apps/files_versions/lib/hooks.php +++ b/apps/files_versions/lib/hooks.php @@ -20,13 +20,10 @@ class Hooks { public static function write_hook( $params ) { if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { - - $versions = new Storage( new \OC\Files\View('') ); - $path = $params[\OC\Files\Filesystem::signal_param_path]; - - if($path<>'') $versions->store( $path ); - + if($path<>'') { + Storage::store($path); + } } } @@ -40,12 +37,10 @@ class Hooks { */ public static function remove_hook($params) { if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { - - $versions = new Storage( new \OC_FilesystemView('') ); - $path = $params[\OC\Files\Filesystem::signal_param_path]; - - if($path<>'') $versions->delete( $path ); + if($path<>'') { + Storage::delete($path); + } } } @@ -59,13 +54,11 @@ class Hooks { */ public static function rename_hook($params) { if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { - - $versions = new Storage( new \OC_FilesystemView('') ); - $oldpath = $params['oldpath']; $newpath = $params['newpath']; - - if($oldpath<>'' && $newpath<>'') $versions->rename( $oldpath, $newpath ); + if($oldpath<>'' && $newpath<>'') { + Storage::rename( $oldpath, $newpath ); + } } } diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index f23381cb156..ba9f8ba41cb 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -35,37 +35,25 @@ class Storage { 'step' => 604800), ); - private static function getUidAndFilename($filename) - { - if (\OCP\App::isEnabled('files_sharing') - && substr($filename, 0, 7) == '/Shared' - && $source = \OCP\Share::getItemSharedWith('file', - substr($filename, 7), - \OC_Share_Backend_File::FORMAT_SHARED_STORAGE)) { - $filename = $source['path']; - $pos = strpos($filename, '/files', 1); - $uid = substr($filename, 1, $pos - 1); - $filename = substr($filename, $pos + 6); - } else { - $uid = \OCP\User::getUser(); + private static function getUidAndFilename($filename) { + $uid = \OC\Files\Filesystem::getOwner($filename); + if ( $uid != \OCP\User::getUser() ) { + $info = \OC\Files\Filesystem::getFileInfo($filename); + $ownerView = new \OC\Files\View('/'.$uid.'/files'); + $filename = $ownerView->getPath($info['fileid']); } return array($uid, $filename); } - + /** * store a new version of a file. */ - public function store($filename) { + public static function store($filename) { if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { list($uid, $filename) = self::getUidAndFilename($filename); - $files_view = new \OC\Files\View('/'.\OCP\User::getUser() .'/files'); - $users_view = new \OC\Files\View('/'.\OCP\User::getUser()); - - //check if source file already exist as version to avoid recursions. - // todo does this check work? - if ($users_view->file_exists($filename)) { - return false; - } + + $files_view = new \OC\Files\View('/'.$uid .'/files'); + $users_view = new \OC\Files\View('/'.$uid); // check if filename is a directory if($files_view->is_dir($filename)) { @@ -106,10 +94,10 @@ class Storage { */ public static function delete($filename) { list($uid, $filename) = self::getUidAndFilename($filename); - $versions_fileview = new \OC_FilesystemView('/'.$uid .'/files_versions'); + $versions_fileview = new \OC\Files\View('/'.$uid .'/files_versions'); $abs_path = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath('').$filename.'.v'; - if( ($versions = self::getVersions($filename)) ) { + if( ($versions = self::getVersions($uid, $filename)) ) { if ( ($versionsSize = \OCP\Config::getAppValue('files_versions', 'size')) === null ) { $versionsSize = self::calculateSize($uid); } @@ -127,16 +115,15 @@ class Storage { public static function rename($oldpath, $newpath) { list($uid, $oldpath) = self::getUidAndFilename($oldpath); list($uidn, $newpath) = self::getUidAndFilename($newpath); - $versions_view = new \OC_FilesystemView('/'.$uid .'/files_versions'); - $files_view = new \OC_FilesystemView('/'.$uid .'/files'); + $versions_view = new \OC\Files\View('/'.$uid .'/files_versions'); + $files_view = new \OC\Files\View('/'.$uid .'/files'); $abs_newpath = \OCP\Config::getSystemValue('datadirectory').$versions_view->getAbsolutePath('').$newpath; if ( $files_view->is_dir($oldpath) && $versions_view->is_dir($oldpath) ) { $versions_view->rename($oldpath, $newpath); - } else if ( ($versions = Storage::getVersions($oldpath)) ) { + } else if ( ($versions = Storage::getVersions($uid, $oldpath)) ) { $info=pathinfo($abs_newpath); if(!file_exists($info['dirname'])) mkdir($info['dirname'], 0750, true); - $versions = Storage::getVersions($oldpath); foreach ($versions as $v) { $versions_view->rename($oldpath.'.v'.$v['version'], $newpath.'.v'.$v['version']); } @@ -177,14 +164,14 @@ class Storage { /** * @brief get a list of all available versions of a file in descending chronological order + * @param $uid user id from the owner of the file * @param $filename file to find versions of, relative to the user files dir * @param $count number of versions to return * @returns array */ - public static function getVersions( $filename, $count = 0 ) { + public static function getVersions($uid, $filename, $count = 0 ) { if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) { - list($uid, $filename) = self::getUidAndFilename($filename); - $versions_fileview = new \OC\Files\View('/' . \OCP\User::getUser() . '/files_versions'); + $versions_fileview = new \OC\Files\View('/' . $uid . '/files_versions'); $versionsName = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename); $versions = array(); @@ -197,7 +184,7 @@ class Storage { sort( $matches ); - $files_view = new \OC_FilesystemView('/'.$uid.'/files'); + $files_view = new \OC\Files\View('/'.$uid.'/files'); $local_file = $files_view->getLocalFile($filename); $local_file_md5 = \md5_file( $local_file ); @@ -248,7 +235,7 @@ class Storage { */ private static function calculateSize($uid) { if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) { - $versions_fileview = new \OC_FilesystemView('/'.$uid.'/files_versions'); + $versions_fileview = new \OC\Files\View('/'.$uid.'/files_versions'); $versionsRoot = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath(''); $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($versionsRoot), \RecursiveIteratorIterator::CHILD_FIRST); @@ -273,7 +260,7 @@ class Storage { */ private static function getAllVersions($uid) { if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) { - $versions_fileview = new \OC_FilesystemView('/'.$uid.'/files_versions'); + $versions_fileview = new \OC\Files\View('/'.$uid.'/files_versions'); $versionsRoot = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath(''); $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($versionsRoot), \RecursiveIteratorIterator::CHILD_FIRST); @@ -319,7 +306,7 @@ class Storage { private static function expire($filename, $versionsSize = null) { if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { list($uid, $filename) = self::getUidAndFilename($filename); - $versions_fileview = new \OC_FilesystemView('/'.$uid.'/files_versions'); + $versions_fileview = new \OC\Files\View('/'.$uid.'/files_versions'); // get available disk space for user $quota = \OCP\Util::computerFileSize(\OC_Preferences::getValue($uid, 'files', 'quota')); @@ -338,7 +325,7 @@ class Storage { } // calculate available space for version history - $files_view = new \OC_FilesystemView('/'.$uid.'/files'); + $files_view = new \OC\Files\View('/'.$uid.'/files'); $rootInfo = $files_view->getFileInfo('/'); $free = $quota-$rootInfo['size']; // remaining free space for user if ( $free > 0 ) { @@ -354,7 +341,7 @@ class Storage { $versions_by_file = $result['by_file']; $all_versions = $result['all']; } else { - $all_versions = Storage::getVersions($filename); + $all_versions = Storage::getVersions($uid, $filename); $versions_by_file[$filename] = $all_versions; } |