summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-01-22 13:19:49 +0100
committerRobin Appelman <icewind@owncloud.com>2014-01-22 13:19:49 +0100
commit02aa44d055292e291a885491bd02b9d315058afb (patch)
treefc0278bffe74689d1d6c35c1ad3e36e29bf06420 /apps
parentb578a3359eecb4113044a32fce3878eb94d10e20 (diff)
parent4474421ada2a4b5642f1a081d6491d7858b3b9b0 (diff)
downloadnextcloud-server-02aa44d055292e291a885491bd02b9d315058afb.tar.gz
nextcloud-server-02aa44d055292e291a885491bd02b9d315058afb.zip
Merge branch 'master' into memcache-public
Diffstat (limited to 'apps')
-rw-r--r--apps/files/ajax/upload.php1
-rw-r--r--apps/files/js/filelist.js7
-rw-r--r--apps/files/js/files.js5
-rw-r--r--apps/files/templates/part.breadcrumb.php6
-rw-r--r--apps/files/templates/part.list.php2
-rw-r--r--apps/files/triggerupdate.php1
-rw-r--r--apps/files_encryption/appinfo/info.xml6
-rw-r--r--apps/files_encryption/lib/proxy.php4
-rwxr-xr-xapps/files_encryption/tests/crypt.php34
-rw-r--r--apps/files_encryption/tests/keymanager.php4
-rw-r--r--apps/files_encryption/tests/proxy.php2
-rw-r--r--apps/files_encryption/tests/stream.php12
-rwxr-xr-xapps/files_encryption/tests/trashbin.php4
-rwxr-xr-xapps/files_encryption/tests/util.php12
-rwxr-xr-xapps/files_encryption/tests/webdav.php2
-rw-r--r--apps/files_external/js/dropbox.js17
-rw-r--r--apps/files_external/js/google.js21
-rw-r--r--apps/files_external/js/settings.js14
-rw-r--r--apps/files_external/lib/webdav.php2
-rw-r--r--apps/files_sharing/ajax/publicpreview.php3
-rw-r--r--apps/files_sharing/appinfo/update.php1
-rw-r--r--apps/files_sharing/css/public.css17
-rw-r--r--apps/files_sharing/js/public.js3
-rw-r--r--apps/files_sharing/lib/watcher.php2
-rw-r--r--apps/files_sharing/public.php12
-rw-r--r--apps/files_sharing/templates/public.php26
-rw-r--r--apps/files_trashbin/lib/trashbin.php8
-rw-r--r--apps/files_versions/ajax/getVersions.php3
-rw-r--r--apps/files_versions/ajax/preview.php10
-rw-r--r--apps/files_versions/lib/versions.php173
-rw-r--r--apps/files_versions/tests/versions.php188
-rw-r--r--apps/user_ldap/lib/helper.php15
32 files changed, 419 insertions, 198 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index 0e905f993ac..bdaf6a77d14 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -34,6 +34,7 @@ if (empty($_POST['dirToken'])) {
// resolve reshares
$rootLinkItem = OCP\Share::resolveReShare($linkItem);
+ OCP\JSON::checkUserExists($rootLinkItem['uid_owner']);
// Setup FS with owner
OC_Util::tearDownFS();
OC_Util::setupFS($rootLinkItem['uid_owner']);
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index c02ab70ce8d..66968ab54c7 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -27,6 +27,8 @@ var FileList={
Files.setupDragAndDrop();
}
FileList.updateFileSummary();
+ procesSelection();
+
$fileList.trigger(jQuery.Event("updated"));
},
createRow:function(type, name, iconurl, linktarget, size, lastModified, permissions) {
@@ -300,7 +302,10 @@ var FileList={
},
remove:function(name){
var fileEl = FileList.findFileEl(name);
- fileEl.find('td.filename').draggable('destroy');
+ if (fileEl.data('permissions') & OC.PERMISSION_DELETE) {
+ // file is only draggable when delete permissions are set
+ fileEl.find('td.filename').draggable('destroy');
+ }
fileEl.remove();
FileList.updateFileSummary();
if ( ! $('tr[data-file]').exists() ) {
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index 1f12ade8d79..76ac87d38ed 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -612,11 +612,12 @@ function procesSelection() {
return el.type==='dir';
});
if (selectedFiles.length === 0 && selectedFolders.length === 0) {
- $('#headerName>span.name').text(t('files','Name'));
+ $('#headerName span.name').text(t('files','Name'));
$('#headerSize').text(t('files','Size'));
$('#modified').text(t('files','Modified'));
$('table').removeClass('multiselect');
$('.selectedActions').hide();
+ $('#select_all').removeAttr('checked');
}
else {
$('.selectedActions').show();
@@ -719,7 +720,7 @@ Files.lazyLoadPreview = function(path, mime, ready, width, height, etag) {
console.warn('Files.lazyLoadPreview(): missing etag argument');
}
- if ( $('#publicUploadButtonMock').length ) {
+ if ( $('#public_upload').length ) {
urlSpec.t = $('#dirToken').val();
previewURL = OC.Router.generate('core_ajax_public_preview', urlSpec);
} else {
diff --git a/apps/files/templates/part.breadcrumb.php b/apps/files/templates/part.breadcrumb.php
index 90d07d4336c..2a0df622767 100644
--- a/apps/files/templates/part.breadcrumb.php
+++ b/apps/files/templates/part.breadcrumb.php
@@ -1,6 +1,10 @@
<div class="crumb <?php if(!count($_["breadcrumb"])) p('last');?>" data-dir=''>
<a href="<?php print_unescaped($_['baseURL']); ?>">
- <img src="<?php print_unescaped(OCP\image_path('core', 'places/home.svg'));?>" class="svg" />
+ <?php if(isset($_['rootBreadCrumb'])):
+ echo $_['rootBreadCrumb'];
+ else:?>
+ <img src="<?php print_unescaped(OCP\image_path('core', 'places/home.svg'));?>" class="svg" />
+ <?php endif;?>
</a>
</div>
<?php for($i=0; $i<count($_["breadcrumb"]); $i++):
diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php
index 2f630e1f014..f4fb96a7a7c 100644
--- a/apps/files/templates/part.list.php
+++ b/apps/files/templates/part.list.php
@@ -18,7 +18,7 @@ $totalsize = 0; ?>
data-size="<?php p($file['size']);?>"
data-etag="<?php p($file['etag']);?>"
data-permissions="<?php p($file['permissions']); ?>">
- <?php if($file['isPreviewAvailable']): ?>
+ <?php if(isset($file['isPreviewAvailable']) and $file['isPreviewAvailable']): ?>
<td class="filename svg preview-icon"
<?php else: ?>
<td class="filename svg"
diff --git a/apps/files/triggerupdate.php b/apps/files/triggerupdate.php
index 0e29edbba35..a37b9823add 100644
--- a/apps/files/triggerupdate.php
+++ b/apps/files/triggerupdate.php
@@ -6,6 +6,7 @@ if (OC::$CLI) {
if (count($argv) === 2) {
$file = $argv[1];
list(, $user) = explode('/', $file);
+ OCP\JSON::checkUserExists($owner);
OC_Util::setupFS($user);
$view = new \OC\Files\View('');
/**
diff --git a/apps/files_encryption/appinfo/info.xml b/apps/files_encryption/appinfo/info.xml
index 9d495916d26..b6d9d6bb0a3 100644
--- a/apps/files_encryption/appinfo/info.xml
+++ b/apps/files_encryption/appinfo/info.xml
@@ -2,11 +2,15 @@
<info>
<id>files_encryption</id>
<name>Encryption</name>
- <description>The new ownCloud 5 files encryption system. After the app was enabled you need to re-login to initialize your encryption keys.</description>
+ <description>The ownCloud files encryption system provides server side-encryption. After the app was enabled you need to re-login to initialize your encryption keys.</description>
<licence>AGPL</licence>
<author>Sam Tuke, Bjoern Schiessle, Florin Peter</author>
<require>4</require>
<shipped>true</shipped>
+ <documentation>
+ <user>http://doc.owncloud.org/server/6.0/user_manual/files/encryption.html</user>
+ <admin>http://doc.owncloud.org/server/6.0/admin_manual/configuration/configuration_encryption.html</admin>
+ </documentation>
<rememberlogin>false</rememberlogin>
<types>
<filesystem/>
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index 41f352d853a..4fe76b97711 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -255,8 +255,8 @@ class Proxy extends \OC_FileProxy {
// split the path parts
$pathParts = explode('/', $path);
- // FIXME: handling for /userId/cache used by webdav for chunking. The cache chunks are NOT encrypted
- if (isset($pathParts[2]) && $pathParts[2] === 'cache') {
+ // don't try to encrypt/decrypt cache chunks or files in the trash bin
+ if (isset($pathParts[2]) && ($pathParts[2] === 'cache' || $pathParts[2] === 'files_trashbin')) {
return $result;
}
diff --git a/apps/files_encryption/tests/crypt.php b/apps/files_encryption/tests/crypt.php
index ca14e3e2ccb..388980ad4fd 100755
--- a/apps/files_encryption/tests/crypt.php
+++ b/apps/files_encryption/tests/crypt.php
@@ -155,7 +155,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
*/
function testSymmetricStreamEncryptShortFileContent() {
- $filename = 'tmp-' . time() . '.test';
+ $filename = 'tmp-' . uniqid() . '.test';
$util = new Encryption\Util(new \OC_FilesystemView(), $this->userId);
@@ -214,7 +214,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
function testSymmetricStreamEncryptLongFileContent() {
// Generate a a random filename
- $filename = 'tmp-' . time() . '.test';
+ $filename = 'tmp-' . uniqid() . '.test';
$util = new Encryption\Util(new \OC_FilesystemView(), $this->userId);
@@ -297,7 +297,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
*/
function testSymmetricStreamDecryptShortFileContent() {
- $filename = 'tmp-' . time();
+ $filename = 'tmp-' . uniqid();
// Save long data as encrypted file using stream wrapper
$cryptedFile = file_put_contents('crypt:///'. $this->userId . '/files/' . $filename, $this->dataShort);
@@ -327,7 +327,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
*/
function testSymmetricStreamDecryptLongFileContent() {
- $filename = 'tmp-' . time();
+ $filename = 'tmp-' . uniqid();
// Save long data as encrypted file using stream wrapper
$cryptedFile = file_put_contents('crypt:///' . $this->userId . '/files/' . $filename, $this->dataLong);
@@ -418,7 +418,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
*/
function testRenameFile() {
- $filename = 'tmp-' . time();
+ $filename = 'tmp-' . uniqid();
// Save long data as encrypted file using stream wrapper
$cryptedFile = file_put_contents('crypt:///' . $this->userId . '/files/' . $filename, $this->dataLong);
@@ -431,7 +431,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
$this->assertEquals($this->dataLong, $decrypt);
- $newFilename = 'tmp-new-' . time();
+ $newFilename = 'tmp-new-' . uniqid();
$view = new \OC\Files\View('/' . $this->userId . '/files');
$view->rename($filename, $newFilename);
@@ -449,7 +449,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
*/
function testMoveFileIntoFolder() {
- $filename = 'tmp-' . time();
+ $filename = 'tmp-' . uniqid();
// Save long data as encrypted file using stream wrapper
$cryptedFile = file_put_contents('crypt:///' . $this->userId . '/files/' . $filename, $this->dataLong);
@@ -462,8 +462,8 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
$this->assertEquals($this->dataLong, $decrypt);
- $newFolder = '/newfolder' . time();
- $newFilename = 'tmp-new-' . time();
+ $newFolder = '/newfolder' . uniqid();
+ $newFilename = 'tmp-new-' . uniqid();
$view = new \OC\Files\View('/' . $this->userId . '/files');
$view->mkdir($newFolder);
$view->rename($filename, $newFolder . '/' . $newFilename);
@@ -484,8 +484,8 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
$view = new \OC\Files\View('/' . $this->userId . '/files');
- $filename = '/tmp-' . time();
- $folder = '/folder' . time();
+ $filename = '/tmp-' . uniqid();
+ $folder = '/folder' . uniqid();
$view->mkdir($folder);
@@ -500,7 +500,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
$this->assertEquals($this->dataLong, $decrypt);
- $newFolder = '/newfolder/subfolder' . time();
+ $newFolder = '/newfolder/subfolder' . uniqid();
$view->mkdir('/newfolder');
$view->rename($folder, $newFolder);
@@ -519,7 +519,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
* @medium
*/
function testChangePassphrase() {
- $filename = 'tmp-' . time();
+ $filename = 'tmp-' . uniqid();
// Save long data as encrypted file using stream wrapper
$cryptedFile = file_put_contents('crypt:///' . $this->userId . '/files/' . $filename, $this->dataLong);
@@ -557,7 +557,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
*/
function testViewFilePutAndGetContents() {
- $filename = '/tmp-' . time();
+ $filename = '/tmp-' . uniqid();
$view = new \OC\Files\View('/' . $this->userId . '/files');
// Save short data as encrypted file using stream wrapper
@@ -590,7 +590,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
* @large
*/
function testTouchExistingFile() {
- $filename = '/tmp-' . time();
+ $filename = '/tmp-' . uniqid();
$view = new \OC\Files\View('/' . $this->userId . '/files');
// Save short data as encrypted file using stream wrapper
@@ -614,7 +614,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
* @medium
*/
function testTouchFile() {
- $filename = '/tmp-' . time();
+ $filename = '/tmp-' . uniqid();
$view = new \OC\Files\View('/' . $this->userId . '/files');
$view->touch($filename);
@@ -638,7 +638,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
* @medium
*/
function testFopenFile() {
- $filename = '/tmp-' . time();
+ $filename = '/tmp-' . uniqid();
$view = new \OC\Files\View('/' . $this->userId . '/files');
// Save short data as encrypted file using stream wrapper
diff --git a/apps/files_encryption/tests/keymanager.php b/apps/files_encryption/tests/keymanager.php
index 1467979f005..58a57ee5af4 100644
--- a/apps/files_encryption/tests/keymanager.php
+++ b/apps/files_encryption/tests/keymanager.php
@@ -143,7 +143,7 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase {
$key = $this->randomKey;
- $file = 'unittest-' . time() . '.txt';
+ $file = 'unittest-' . uniqid() . '.txt';
$util = new Encryption\Util($this->view, $this->userId);
@@ -196,7 +196,7 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase {
function testRecursiveDelShareKeys() {
// generate filename
- $filename = '/tmp-' . time() . '.txt';
+ $filename = '/tmp-' . uniqid() . '.txt';
// create folder structure
$this->view->mkdir('/'.Test_Encryption_Keymanager::TEST_USER.'/files/folder1');
diff --git a/apps/files_encryption/tests/proxy.php b/apps/files_encryption/tests/proxy.php
index 419f95e1a38..c3006274d6d 100644
--- a/apps/files_encryption/tests/proxy.php
+++ b/apps/files_encryption/tests/proxy.php
@@ -80,7 +80,7 @@ class Test_Encryption_Proxy extends \PHPUnit_Framework_TestCase {
// init short data
$this->data = 'hats';
- $this->filename = 'enc_proxy_tests-' . time() . '.txt';
+ $this->filename = 'enc_proxy_tests-' . uniqid() . '.txt';
}
diff --git a/apps/files_encryption/tests/stream.php b/apps/files_encryption/tests/stream.php
index 2767bbe512b..fed2e7d89d1 100644
--- a/apps/files_encryption/tests/stream.php
+++ b/apps/files_encryption/tests/stream.php
@@ -99,7 +99,7 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase {
}
function testStreamOptions() {
- $filename = '/tmp-' . time();
+ $filename = '/tmp-' . uniqid();
$view = new \OC\Files\View('/' . $this->userId . '/files');
// Save short data as encrypted file using stream wrapper
@@ -122,7 +122,7 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase {
}
function testStreamSetBlocking() {
- $filename = '/tmp-' . time();
+ $filename = '/tmp-' . uniqid();
$view = new \OC\Files\View('/' . $this->userId . '/files');
// Save short data as encrypted file using stream wrapper
@@ -144,7 +144,7 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase {
* @medium
*/
function testStreamSetTimeout() {
- $filename = '/tmp-' . time();
+ $filename = '/tmp-' . uniqid();
$view = new \OC\Files\View('/' . $this->userId . '/files');
// Save short data as encrypted file using stream wrapper
@@ -163,7 +163,7 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase {
}
function testStreamSetWriteBuffer() {
- $filename = '/tmp-' . time();
+ $filename = '/tmp-' . uniqid();
$view = new \OC\Files\View('/' . $this->userId . '/files');
// Save short data as encrypted file using stream wrapper
@@ -187,9 +187,9 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase {
*/
function testStreamFromLocalFile() {
- $filename = '/' . $this->userId . '/files/' . 'tmp-' . time().'.txt';
+ $filename = '/' . $this->userId . '/files/' . 'tmp-' . uniqid().'.txt';
- $tmpFilename = "/tmp/" . time() . ".txt";
+ $tmpFilename = "/tmp/" . uniqid() . ".txt";
// write an encrypted file
$cryptedFile = $this->view->file_put_contents($filename, $this->dataShort);
diff --git a/apps/files_encryption/tests/trashbin.php b/apps/files_encryption/tests/trashbin.php
index 2a41ace4015..2f9ecfd9d5d 100755
--- a/apps/files_encryption/tests/trashbin.php
+++ b/apps/files_encryption/tests/trashbin.php
@@ -119,7 +119,7 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase {
function testDeleteFile() {
// generate filename
- $filename = 'tmp-' . time() . '.txt';
+ $filename = 'tmp-' . uniqid() . '.txt';
// save file with content
$cryptedFile = file_put_contents('crypt:///' .\Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1. '/files/'. $filename, $this->dataShort);
@@ -223,7 +223,7 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase {
function testPermanentDeleteFile() {
// generate filename
- $filename = 'tmp-' . time() . '.txt';
+ $filename = 'tmp-' . uniqid() . '.txt';
// save file with content
$cryptedFile = file_put_contents('crypt:///' .$this->userId. '/files/' . $filename, $this->dataShort);
diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php
index b1904cbadc7..97e3c518dac 100755
--- a/apps/files_encryption/tests/util.php
+++ b/apps/files_encryption/tests/util.php
@@ -142,8 +142,8 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
self::loginHelper($this->userId);
- $unencryptedFile = '/tmpUnencrypted-' . time() . '.txt';
- $encryptedFile = '/tmpEncrypted-' . time() . '.txt';
+ $unencryptedFile = '/tmpUnencrypted-' . uniqid() . '.txt';
+ $encryptedFile = '/tmpEncrypted-' . uniqid() . '.txt';
// Disable encryption proxy to write a unencrypted file
$proxyStatus = \OC_FileProxy::$enabled;
@@ -254,7 +254,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
\OC_User::setUserId(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1);
- $filename = '/tmp-' . time() . '.test';
+ $filename = '/tmp-' . uniqid() . '.test';
// Disable encryption proxy to prevent recursive calls
$proxyStatus = \OC_FileProxy::$enabled;
@@ -282,7 +282,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
function testGetFileSize() {
\Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1);
- $filename = 'tmp-' . time();
+ $filename = 'tmp-' . uniqid();
$externalFilename = '/' . $this->userId . '/files/' . $filename;
// Test for 0 byte files
@@ -318,7 +318,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
function testEncryptAll() {
- $filename = "/encryptAll" . time() . ".txt";
+ $filename = "/encryptAll" . uniqid() . ".txt";
$util = new Encryption\Util($this->view, $this->userId);
// disable encryption to upload a unencrypted file
@@ -350,7 +350,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
function testDecryptAll() {
- $filename = "/decryptAll" . time() . ".txt";
+ $filename = "/decryptAll" . uniqid() . ".txt";
$util = new Encryption\Util($this->view, $this->userId);
$this->view->file_put_contents($this->userId . '/files/' . $filename, $this->dataShort);
diff --git a/apps/files_encryption/tests/webdav.php b/apps/files_encryption/tests/webdav.php
index a2a8ce6e34f..8e8b9c53cee 100755
--- a/apps/files_encryption/tests/webdav.php
+++ b/apps/files_encryption/tests/webdav.php
@@ -113,7 +113,7 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase {
function testWebdavPUT() {
// generate filename
- $filename = '/tmp-' . time() . '.txt';
+ $filename = '/tmp-' . uniqid() . '.txt';
// set server vars
$_SERVER['REQUEST_METHOD'] = 'OPTIONS';
diff --git a/apps/files_external/js/dropbox.js b/apps/files_external/js/dropbox.js
index 957daeb4d1f..6baaabe11b6 100644
--- a/apps/files_external/js/dropbox.js
+++ b/apps/files_external/js/dropbox.js
@@ -23,9 +23,12 @@ $(document).ready(function() {
$(token).val(result.access_token);
$(token_secret).val(result.access_token_secret);
$(configured).val('true');
- OC.MountConfig.saveStorage(tr);
- $(tr).find('.configuration input').attr('disabled', 'disabled');
- $(tr).find('.configuration').append('<span id="access" style="padding-left:0.5em;">'+t('files_external', 'Access granted')+'</span>');
+ OC.MountConfig.saveStorage(tr, function(status) {
+ if (status) {
+ $(tr).find('.configuration input').attr('disabled', 'disabled');
+ $(tr).find('.configuration').append('<span id="access" style="padding-left:0.5em;">'+t('files_external', 'Access granted')+'</span>');
+ }
+ });
} else {
OC.dialogs.alert(result.data.message, t('files_external', 'Error configuring Dropbox storage'));
}
@@ -77,7 +80,6 @@ $(document).ready(function() {
var tr = $(this).parent().parent();
var app_key = $(this).parent().find('[data-parameter="app_key"]').val();
var app_secret = $(this).parent().find('[data-parameter="app_secret"]').val();
- var statusSpan = $(tr).find('.status span');
if (app_key != '' && app_secret != '') {
var tr = $(this).parent().parent();
var configured = $(this).parent().find('[data-parameter="configured"]');
@@ -88,10 +90,9 @@ $(document).ready(function() {
$(configured).val('false');
$(token).val(result.data.request_token);
$(token_secret).val(result.data.request_token_secret);
- OC.MountConfig.saveStorage(tr);
- statusSpan.removeClass();
- statusSpan.addClass('waiting');
- window.location = result.data.url;
+ OC.MountConfig.saveStorage(tr, function() {
+ window.location = result.data.url;
+ });
} else {
OC.dialogs.alert(result.data.message, t('files_external', 'Error configuring Dropbox storage'));
}
diff --git a/apps/files_external/js/google.js b/apps/files_external/js/google.js
index b4be1c1dc41..068c2c13c66 100644
--- a/apps/files_external/js/google.js
+++ b/apps/files_external/js/google.js
@@ -32,11 +32,14 @@ $(document).ready(function() {
if (result && result.status == 'success') {
$(token).val(result.data.token);
$(configured).val('true');
- OC.MountConfig.saveStorage(tr);
- $(tr).find('.configuration input').attr('disabled', 'disabled');
- $(tr).find('.configuration').append($('<span/>')
- .attr('id', 'access')
- .text(t('files_external', 'Access granted')));
+ OC.MountConfig.saveStorage(tr, function(status) {
+ if (status) {
+ $(tr).find('.configuration input').attr('disabled', 'disabled');
+ $(tr).find('.configuration').append($('<span/>')
+ .attr('id', 'access')
+ .text(t('files_external', 'Access granted')));
+ }
+ });
} else {
OC.dialogs.alert(result.data.message,
t('files_external', 'Error configuring Google Drive storage')
@@ -99,7 +102,6 @@ $(document).ready(function() {
var configured = $(this).parent().find('[data-parameter="configured"]');
var client_id = $(this).parent().find('[data-parameter="client_id"]').val();
var client_secret = $(this).parent().find('[data-parameter="client_secret"]').val();
- var statusSpan = $(tr).find('.status span');
if (client_id != '' && client_secret != '') {
var token = $(this).parent().find('[data-parameter="token"]');
$.post(OC.filePath('files_external', 'ajax', 'google.php'),
@@ -112,10 +114,9 @@ $(document).ready(function() {
if (result && result.status == 'success') {
$(configured).val('false');
$(token).val('false');
- OC.MountConfig.saveStorage(tr);
- statusSpan.removeClass();
- statusSpan.addClass('waiting');
- window.location = result.data.url;
+ OC.MountConfig.saveStorage(tr, function(status) {
+ window.location = result.data.url;
+ });
} else {
OC.dialogs.alert(result.data.message,
t('files_external', 'Error configuring Google Drive storage')
diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js
index 886c324e338..895f97bd2c3 100644
--- a/apps/files_external/js/settings.js
+++ b/apps/files_external/js/settings.js
@@ -12,7 +12,7 @@ function updateStatus(statusEl, result){
}
OC.MountConfig={
- saveStorage:function(tr) {
+ saveStorage:function(tr, callback) {
var mountPoint = $(tr).find('.mountPoint input').val();
if (mountPoint == '') {
return false;
@@ -84,9 +84,15 @@ OC.MountConfig={
},
success: function(result) {
status = updateStatus(statusSpan, result);
+ if (callback) {
+ callback(status);
+ }
},
error: function(result){
status = updateStatus(statusSpan, result);
+ if (callback) {
+ callback(status);
+ }
}
});
});
@@ -137,9 +143,15 @@ OC.MountConfig={
},
success: function(result) {
status = updateStatus(statusSpan, result);
+ if (callback) {
+ callback(status);
+ }
},
error: function(result){
status = updateStatus(statusSpan, result);
+ if (callback) {
+ callback(status);
+ }
}
});
}
diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php
index 0f8034e57d9..f6f4cb16e87 100644
--- a/apps/files_external/lib/webdav.php
+++ b/apps/files_external/lib/webdav.php
@@ -224,7 +224,7 @@ class DAV extends \OC\Files\Storage\Common{
if (isset($response['{DAV:}quota-available-bytes'])) {
return (int)$response['{DAV:}quota-available-bytes'];
} else {
- return 0;
+ return \OC\Files\SPACE_UNKNOWN;
}
} catch(\Exception $e) {
return \OC\Files\SPACE_UNKNOWN;
diff --git a/apps/files_sharing/ajax/publicpreview.php b/apps/files_sharing/ajax/publicpreview.php
index 54a9806e8bf..a52f522afac 100644
--- a/apps/files_sharing/ajax/publicpreview.php
+++ b/apps/files_sharing/ajax/publicpreview.php
@@ -39,6 +39,7 @@ if(!isset($linkedItem['uid_owner']) || !isset($linkedItem['file_source'])) {
$rootLinkItem = OCP\Share::resolveReShare($linkedItem);
$userId = $rootLinkItem['uid_owner'];
+OCP\JSON::checkUserExists($rootLinkItem['uid_owner']);
\OC_Util::setupFS($userId);
\OC\Files\Filesystem::initMountPoints($userId);
$view = new \OC\Files\View('/' . $userId . '/files');
@@ -88,4 +89,4 @@ try{
} catch (\Exception $e) {
\OC_Response::setStatus(500);
\OC_Log::write('core', $e->getmessage(), \OC_Log::DEBUG);
-} \ No newline at end of file
+}
diff --git a/apps/files_sharing/appinfo/update.php b/apps/files_sharing/appinfo/update.php
index 0d827da28ea..4b716e764f4 100644
--- a/apps/files_sharing/appinfo/update.php
+++ b/apps/files_sharing/appinfo/update.php
@@ -44,6 +44,7 @@ if (version_compare($installedVersion, '0.3', '<')) {
$shareType = OCP\Share::SHARE_TYPE_USER;
$shareWith = $row['uid_shared_with'];
}
+ OCP\JSON::checkUserExists($row['uid_owner']);
OC_User::setUserId($row['uid_owner']);
//we need to setup the filesystem for the user, otherwise OC_FileSystem::getRoot will fail and break
OC_Util::setupFS($row['uid_owner']);
diff --git a/apps/files_sharing/css/public.css b/apps/files_sharing/css/public.css
index 060d4dfedc7..f4121430b9e 100644
--- a/apps/files_sharing/css/public.css
+++ b/apps/files_sharing/css/public.css
@@ -141,10 +141,13 @@ thead{
.directLink {
margin-bottom: 20px;
}
- .directLink label {
- font-weight: normal;
- }
- .directLink input {
- margin-left: 10px;
- width: 300px;
- }
+.directLink label {
+ font-weight: normal;
+}
+.directLink input {
+ margin-left: 10px;
+ width: 300px;
+}
+.public_actions {
+ padding: 4px;
+}
diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js
index 2e34e6f9bc5..4c0b0ad9d48 100644
--- a/apps/files_sharing/js/public.js
+++ b/apps/files_sharing/js/public.js
@@ -59,7 +59,8 @@ $(document).ready(function() {
});
// Add Uploadprogress Wrapper to controls bar
- $('#controls').append($('#additional_controls div#uploadprogresswrapper'));
+ $('#controls').append($('#controls .actions div#uploadprogresswrapper'));
+ $('#uploadprogresswrapper').addClass('public_actions');
// Cancel upload trigger
$('#cancel_upload_button').click(function() {
diff --git a/apps/files_sharing/lib/watcher.php b/apps/files_sharing/lib/watcher.php
index c40cf6911b8..285b1a58c6e 100644
--- a/apps/files_sharing/lib/watcher.php
+++ b/apps/files_sharing/lib/watcher.php
@@ -32,7 +32,7 @@ class Shared_Watcher extends Watcher {
* @param string $path
*/
public function checkUpdate($path) {
- if ($path != '' && parent::checkUpdate($path)) {
+ if ($path != '' && parent::checkUpdate($path) === true) {
// since checkUpdate() has already updated the size of the subdirs,
// only apply the update to the owner's parent dirs
diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php
index f4042f65248..4a81e482970 100644
--- a/apps/files_sharing/public.php
+++ b/apps/files_sharing/public.php
@@ -35,7 +35,7 @@ function determineIcon($file, $sharingRoot, $sharingToken) {
if (isset($_GET['t'])) {
$token = $_GET['t'];
- $linkItem = OCP\Share::getShareByToken($token);
+ $linkItem = OCP\Share::getShareByToken($token, false);
if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
// seems to be a valid share
$type = $linkItem['item_type'];
@@ -43,10 +43,10 @@ if (isset($_GET['t'])) {
$shareOwner = $linkItem['uid_owner'];
$path = null;
$rootLinkItem = OCP\Share::resolveReShare($linkItem);
- $fileOwner = $rootLinkItem['uid_owner'];
- if (isset($fileOwner)) {
+ if (isset($rootLinkItem['uid_owner'])) {
+ OCP\JSON::checkUserExists($rootLinkItem['uid_owner']);
OC_Util::tearDownFS();
- OC_Util::setupFS($fileOwner);
+ OC_Util::setupFS($rootLinkItem['uid_owner']);
$path = \OC\Files\Filesystem::getPath($linkItem['file_source']);
}
}
@@ -111,6 +111,7 @@ if (isset($path)) {
}
}
$basePath = $path;
+ $rootName = basename($path);
if (isset($_GET['path']) && \OC\Files\Filesystem::isReadable($basePath . $_GET['path'])) {
$getPath = \OC\Files\Filesystem::normalizePath($_GET['path']);
$path .= $getPath;
@@ -188,8 +189,8 @@ if (isset($path)) {
} else {
$i['extension'] = '';
}
- $i['isPreviewAvailable'] = \OC::$server->getPreviewManager()->isMimeSupported($i['mimetype']);
}
+ $i['isPreviewAvailable'] = \OC::$server->getPreviewManager()->isMimeSupported($i['mimetype']);
$i['directory'] = $getPath;
$i['permissions'] = OCP\PERMISSION_READ;
$i['icon'] = determineIcon($i, $basePath, $token);
@@ -216,6 +217,7 @@ if (isset($path)) {
$list->assign('sharingroot', $basePath);
$breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
$breadcrumbNav->assign('breadcrumb', $breadcrumb);
+ $breadcrumbNav->assign('rootBreadCrumb', $rootName);
$breadcrumbNav->assign('baseURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&path=');
$maxUploadFilesize=OCP\Util::maxUploadFilesize($path);
$fileHeader = (!isset($files) or count($files) > 0);
diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php
index 1d527dca8eb..8b5e0976412 100644
--- a/apps/files_sharing/templates/public.php
+++ b/apps/files_sharing/templates/public.php
@@ -24,9 +24,10 @@
<?php if (!isset($_['folder']) || $_['allowZipDownload']): ?>
- <a href="<?php p($_['downloadURL']); ?>" class="button" id="download"><img
- class="svg" alt="Download" src="<?php print_unescaped(OCP\image_path("core", "actions/download.svg")); ?>"
- /><span><?php p($l->t('Download'))?></span></a>
+ <a href="<?php p($_['downloadURL']); ?>" class="button" id="download">
+ <img class="svg" alt="Download" src="<?php print_unescaped(OCP\image_path("core", "actions/download.svg")); ?>" />
+ <span><?php p($l->t('Download'))?></span>
+ </a>
<?php endif; ?>
<?php if ($_['allowPublicUploadEnabled']):?>
@@ -43,28 +44,17 @@
<?php endif;?>
- <div id="data-upload-form" class="button" title="<?php p($l->t('Upload') . ' max. '.$_['uploadMaxHumanFilesize']) ?>">
+ <div id="data-upload-form" title="<?php p($l->t('Upload') . ' max. '.$_['uploadMaxHumanFilesize']) ?>">
<input id="file_upload_start" type="file" name="files[]" data-url="<?php print_unescaped(OCP\Util::linkTo('files', 'ajax/upload.php')); ?>" multiple>
- <a href="#" id="publicUploadButtonMock" class="svg">
+ <a href="#" id="public_upload" class="button">
+ <img class="svg" alt="Upload" src="<?php print_unescaped(OCP\image_path("core", "actions/upload.svg")); ?>" />
<span><?php p($l->t('Upload'))?></span>
</a>
</div>
</div>
-
- <div id="additional_controls" style="display:none">
- <div id="uploadprogresswrapper">
- <div id="uploadprogressbar"></div>
- <input id="cancel_upload_button" type="button" class="stop" style="display:none"
- value="<?php p($l->t('Cancel upload'));?>"
- />
- </div>
-
-
-
-
+ <div>
<?php endif; ?>
-
</div>
</div></header>
<div id="content">
diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php
index 567f88b91b1..7544980e071 100644
--- a/apps/files_trashbin/lib/trashbin.php
+++ b/apps/files_trashbin/lib/trashbin.php
@@ -189,7 +189,7 @@ class Trashbin {
if ($rootView->is_dir($owner . '/files_versions/' . $ownerPath)) {
$size += self::calculateSize(new \OC\Files\View('/' . $owner . '/files_versions/' . $ownerPath));
if ($owner !== $user) {
- $rootView->copy($owner . '/files_versions/' . $ownerPath, $owner . '/files_trashbin/versions/' . basename($ownerPath) . '.d' . $timestamp);
+ self::copy_recursive($owner . '/files_versions/' . $ownerPath, $owner . '/files_trashbin/versions/' . basename($ownerPath) . '.d' . $timestamp, $rootView);
}
$rootView->rename($owner . '/files_versions/' . $ownerPath, $user . '/files_trashbin/versions/' . $filename . '.d' . $timestamp);
} else if ($versions = \OCA\Files_Versions\Storage::getVersions($owner, $ownerPath)) {
@@ -247,7 +247,7 @@ class Trashbin {
if ($rootView->is_dir($keyfile)) {
$size += self::calculateSize(new \OC\Files\View($keyfile));
if ($owner !== $user) {
- $rootView->copy($keyfile, $owner . '/files_trashbin/keyfiles/' . basename($ownerPath) . '.d' . $timestamp);
+ self::copy_recursive($keyfile, $owner . '/files_trashbin/keyfiles/' . basename($ownerPath) . '.d' . $timestamp, $rootView);
}
$rootView->rename($keyfile, $user . '/files_trashbin/keyfiles/' . $filename . '.d' . $timestamp);
} else {
@@ -265,7 +265,7 @@ class Trashbin {
if ($rootView->is_dir($sharekeys)) {
$size += self::calculateSize(new \OC\Files\View($sharekeys));
if ($owner !== $user) {
- $rootView->copy($sharekeys, $owner . '/files_trashbin/share-keys/' . basename($ownerPath) . '.d' . $timestamp);
+ self::copy_recursive($sharekeys, $owner . '/files_trashbin/share-keys/' . basename($ownerPath) . '.d' . $timestamp, $rootView);
}
$rootView->rename($sharekeys, $user . '/files_trashbin/share-keys/' . $filename . '.d' . $timestamp);
} else {
@@ -734,7 +734,7 @@ class Trashbin {
// calculate available space for trash bin
// subtract size of files and current trash bin size from quota
if ($softQuota) {
- $rootInfo = $view->getFileInfo('/files/');
+ $rootInfo = $view->getFileInfo('/files/', false);
$free = $quota - $rootInfo['size']; // remaining free space for user
if ($free > 0) {
$availableSpace = ($free * self::DEFAULTMAXSIZE / 100) - $trashbinSize; // how much space can be used for versions
diff --git a/apps/files_versions/ajax/getVersions.php b/apps/files_versions/ajax/getVersions.php
index 4f48f71d8ca..4cc1c428898 100644
--- a/apps/files_versions/ajax/getVersions.php
+++ b/apps/files_versions/ajax/getVersions.php
@@ -5,7 +5,8 @@ $source = $_GET['source'];
$start = $_GET['start'];
list ($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($source);
$count = 5; //show the newest revisions
-if( ($versions = OCA\Files_Versions\Storage::getVersions($uid, $filename)) ) {
+$versions = OCA\Files_Versions\Storage::getVersions($uid, $filename, $source);
+if( $versions ) {
$endReached = false;
if (count($versions) <= $start+$count) {
diff --git a/apps/files_versions/ajax/preview.php b/apps/files_versions/ajax/preview.php
index 31525028ef3..bd9b7366ab0 100644
--- a/apps/files_versions/ajax/preview.php
+++ b/apps/files_versions/ajax/preview.php
@@ -12,18 +12,11 @@ if(!\OC_App::isEnabled('files_versions')){
}
$file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : '';
-$user = array_key_exists('user', $_GET) ? $_GET['user'] : '';
$maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : 44;
$maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : 44;
$version = array_key_exists('version', $_GET) ? $_GET['version'] : '';
$scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true;
-if($user === '') {
- \OC_Response::setStatus(400); //400 Bad Request
- \OC_Log::write('versions-preview', 'No user parameter was passed', \OC_Log::DEBUG);
- exit;
-}
-
if($file === '' && $version === '') {
\OC_Response::setStatus(400); //400 Bad Request
\OC_Log::write('versions-preview', 'No file parameter was passed', \OC_Log::DEBUG);
@@ -36,7 +29,8 @@ if($maxX === 0 || $maxY === 0) {
exit;
}
-try{
+try {
+ list($user, $file) = \OCA\Files_Versions\Storage::getUidAndFilename($file);
$preview = new \OC\Preview($user, 'files_versions', $file.'.v'.$version);
$mimetype = \OC_Helper::getFileNameMimeType($file);
$preview->setMimetype($mimetype);
diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php
index 7e6cc818efb..328ed4305f4 100644
--- a/apps/files_versions/lib/versions.php
+++ b/apps/files_versions/lib/versions.php
@@ -261,11 +261,12 @@ 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
- * @returns array
+ * @param string $uid user id from the owner of the file
+ * @param string $filename file to find versions of, relative to the user files dir
+ * @param string $userFullPath
+ * @returns array versions newest version first
*/
- public static function getVersions($uid, $filename) {
+ public static function getVersions($uid, $filename, $userFullPath = '') {
$versions = array();
// fetch for old versions
$view = new \OC\Files\View('/' . $uid . '/' . self::VERSIONS_ROOT);
@@ -286,7 +287,11 @@ class Storage {
$versions[$key]['cur'] = 0;
$versions[$key]['version'] = $version;
$versions[$key]['humanReadableTimestamp'] = self::getHumanReadableTimestamp($version);
- $versions[$key]['preview'] = \OCP\Util::linkToRoute('core_ajax_versions_preview', array('file' => $filename, 'version' => $version, 'user' => $uid));
+ if (empty($userFullPath)) {
+ $versions[$key]['preview'] = '';
+ } else {
+ $versions[$key]['preview'] = \OCP\Util::linkToRoute('core_ajax_versions_preview', array('file' => $userFullPath, 'version' => $version));
+ }
$versions[$key]['path'] = $filename;
$versions[$key]['name'] = $versionedFile;
$versions[$key]['size'] = $file['size'];
@@ -392,12 +397,13 @@ class Storage {
}
}
- ksort($versions);
+ // newest version first
+ krsort($versions);
$result = array();
foreach ($versions as $key => $value) {
- $size = $view->filesize($value['path']);
+ $size = $view->filesize(self::VERSIONS_ROOT.'/'.$value['path'].'.v'.$value['timestamp']);
$filename = $value['path'];
$result['all'][$key]['version'] = $value['timestamp'];
@@ -413,6 +419,63 @@ class Storage {
}
/**
+ * @brief get list of files we want to expire
+ * @param int $currentTime timestamp of current time
+ * @param array $versions list of versions
+ * @return array containing the list of to deleted versions and the size of them
+ */
+ protected static function getExpireList($time, $versions) {
+
+ $size = 0;
+ $toDelete = array(); // versions we want to delete
+
+ $interval = 1;
+ $step = Storage::$max_versions_per_interval[$interval]['step'];
+ if (Storage::$max_versions_per_interval[$interval]['intervalEndsAfter'] == -1) {
+ $nextInterval = -1;
+ } else {
+ $nextInterval = $time - Storage::$max_versions_per_interval[$interval]['intervalEndsAfter'];
+ }
+
+ $firstVersion = reset($versions);
+ $firstKey = key($versions);
+ $prevTimestamp = $firstVersion['version'];
+ $nextVersion = $firstVersion['version'] - $step;
+ unset($versions[$firstKey]);
+
+ foreach ($versions as $key => $version) {
+ $newInterval = true;
+ while ($newInterval) {
+ if ($nextInterval == -1 || $prevTimestamp > $nextInterval) {
+ if ($version['version'] > $nextVersion) {
+ //distance between two version too small, mark to delete
+ $toDelete[$key] = $version['path'] . '.v' . $version['version'];
+ $size += $version['size'];
+ \OCP\Util::writeLog('files_versions', 'Mark to expire '. $version['path'] .' next version should be ' . $nextVersion . " or smaller. (prevTimestamp: " . $prevTimestamp . "; step: " . $step, \OCP\Util::DEBUG);
+ } else {
+ $nextVersion = $version['version'] - $step;
+ $prevTimestamp = $version['version'];
+ }
+ $newInterval = false; // version checked so we can move to the next one
+ } else { // time to move on to the next interval
+ $interval++;
+ $step = Storage::$max_versions_per_interval[$interval]['step'];
+ $nextVersion = $prevTimestamp - $step;
+ if (Storage::$max_versions_per_interval[$interval]['intervalEndsAfter'] == -1) {
+ $nextInterval = -1;
+ } else {
+ $nextInterval = $time - Storage::$max_versions_per_interval[$interval]['intervalEndsAfter'];
+ }
+ $newInterval = true; // we changed the interval -> check same version with new interval
+ }
+ }
+ }
+
+ return array($toDelete, $size);
+
+ }
+
+ /**
* @brief Erase a file's versions which exceed the set quota
*/
private static function expire($filename, $versionsSize = null, $offset = 0) {
@@ -445,7 +508,7 @@ class Storage {
// subtract size of files and current versions size from quota
if ($softQuota) {
$files_view = new \OC\Files\View('/'.$uid.'/files');
- $rootInfo = $files_view->getFileInfo('/');
+ $rootInfo = $files_view->getFileInfo('/', false);
$free = $quota-$rootInfo['size']; // remaining free space for user
if ( $free > 0 ) {
$availableSpace = ($free * self::DEFAULTMAXSIZE / 100) - ($versionsSize + $offset); // how much space can be used for versions
@@ -456,33 +519,35 @@ class Storage {
$availableSpace = $quota - $offset;
}
-
- // with the probability of 0.1% we reduce the number of all versions not only for the current file
- $random = rand(0, 1000);
- if ($random == 0) {
- $allFiles = true;
- } else {
- $allFiles = false;
- }
-
$allVersions = Storage::getVersions($uid, $filename);
- $versionsByFile[$filename] = $allVersions;
- $sizeOfDeletedVersions = self::delOldVersions($versionsByFile, $allVersions, $versionsFileview);
+ $time = time();
+ list($toDelete, $sizeOfDeletedVersions) = self::getExpireList($time, $allVersions);
+
$availableSpace = $availableSpace + $sizeOfDeletedVersions;
$versionsSize = $versionsSize - $sizeOfDeletedVersions;
// if still not enough free space we rearrange the versions from all files
- if ($availableSpace <= 0 || $allFiles) {
+ if ($availableSpace <= 0) {
$result = Storage::getAllVersions($uid);
- $versionsByFile = $result['by_file'];
$allVersions = $result['all'];
- $sizeOfDeletedVersions = self::delOldVersions($versionsByFile, $allVersions, $versionsFileview);
+ foreach ($result['by_file'] as $versions) {
+ list($toDeleteNew, $size) = self::getExpireList($time, $versions);
+ $toDelete = array_merge($toDelete, $toDeleteNew);
+ $sizeOfDeletedVersions += $size;
+ }
$availableSpace = $availableSpace + $sizeOfDeletedVersions;
$versionsSize = $versionsSize - $sizeOfDeletedVersions;
}
+ foreach($toDelete as $key => $path) {
+ \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path));
+ $versionsFileview->unlink($path);
+ unset($allVersions[$key]); // update array with the versions we keep
+ \OCP\Util::writeLog('files_versions', "Expire: " . $path, \OCP\Util::DEBUG);
+ }
+
// Check if enough space is available after versions are rearranged.
// If not we delete the oldest versions until we meet the size limit for versions,
// but always keep the two latest versions
@@ -492,6 +557,7 @@ class Storage {
$version = current($allVersions);
$versionsFileview->unlink($version['path'].'.v'.$version['version']);
\OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'].'.v'.$version['version']));
+ \OCP\Util::writeLog('files_versions', 'running out of space! Delete oldest version: ' . $version['path'].'.v'.$version['version'] , \OCP\Util::DEBUG);
$versionsSize -= $version['size'];
$availableSpace += $version['size'];
next($allVersions);
@@ -505,69 +571,6 @@ class Storage {
}
/**
- * @brief delete old version from a given list of versions
- *
- * @param array $versionsByFile list of versions ordered by files
- * @param array $allVversions all versions accross multiple files
- * @param $versionsFileview OC\Files\View on data/user/files_versions
- * @return size of releted versions
- */
- private static function delOldVersions($versionsByFile, &$allVersions, $versionsFileview) {
-
- $time = time();
- $size = 0;
-
- // delete old versions for every given file
- foreach ($versionsByFile as $versions) {
- $versions = array_reverse($versions); // newest version first
-
- $interval = 1;
- $step = Storage::$max_versions_per_interval[$interval]['step'];
- if (Storage::$max_versions_per_interval[$interval]['intervalEndsAfter'] == -1) {
- $nextInterval = -1;
- } else {
- $nextInterval = $time - Storage::$max_versions_per_interval[$interval]['intervalEndsAfter'];
- }
-
- $firstVersion = reset($versions);
- $firstKey = key($versions);
- $prevTimestamp = $firstVersion['version'];
- $nextVersion = $firstVersion['version'] - $step;
- unset($versions[$firstKey]);
-
- foreach ($versions as $key => $version) {
- $newInterval = true;
- while ($newInterval) {
- if ($nextInterval == -1 || $version['version'] >= $nextInterval) {
- if ($version['version'] > $nextVersion) {
- //distance between two version too small, delete version
- $versionsFileview->unlink($version['path'] . '.v' . $version['version']);
- \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'] . '.v' . $version['version']));
- $size += $version['size'];
- unset($allVersions[$key]); // update array with all versions
- } else {
- $nextVersion = $version['version'] - $step;
- }
- $newInterval = false; // version checked so we can move to the next one
- } else { // time to move on to the next interval
- $interval++;
- $step = Storage::$max_versions_per_interval[$interval]['step'];
- $nextVersion = $prevTimestamp - $step;
- if (Storage::$max_versions_per_interval[$interval]['intervalEndsAfter'] == -1) {
- $nextInterval = -1;
- } else {
- $nextInterval = $time - Storage::$max_versions_per_interval[$interval]['intervalEndsAfter'];
- }
- $newInterval = true; // we changed the interval -> check same version with new interval
- }
- }
- $prevTimestamp = $version['version'];
- }
- }
- return $size;
- }
-
- /**
* @brief create recursively missing directories
* @param string $filename $path to a file
* @param \OC\Files\View $view view on data/user/
diff --git a/apps/files_versions/tests/versions.php b/apps/files_versions/tests/versions.php
new file mode 100644
index 00000000000..25490aa1a04
--- /dev/null
+++ b/apps/files_versions/tests/versions.php
@@ -0,0 +1,188 @@
+<?php
+/**
+ * ownCloud
+ *
+ * @author Bjoern Schiessle
+ * @copyright 2014 Bjoern Schiessle <schiessle@owncloud.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+require_once __DIR__ . '/../lib/versions.php';
+
+/**
+ * Class Test_Files_versions
+ * @brief this class provide basic files versions test
+ */
+class Test_Files_Versioning extends \PHPUnit_Framework_TestCase {
+
+
+ /**
+ * @medium
+ * @brief test expire logic
+ * @dataProvider versionsProvider
+ */
+ function testGetExpireList($versions, $sizeOfAllDeletedFiles) {
+
+ // last interval enda at 2592000
+ $startTime = 5000000;
+
+ $testClass = new VersionStorageToTest();
+ list($deleted, $size) = $testClass->callProtectedGetExpireList($startTime, $versions);
+
+ // we should have deleted 16 files each of the size 1
+ $this->assertEquals($sizeOfAllDeletedFiles, $size);
+
+ // the deleted array should only contain versions which should be deleted
+ foreach($deleted as $key => $path) {
+ unset($versions[$key]);
+ $this->assertEquals("delete", substr($path, 0, strlen("delete")));
+ }
+
+ // the versions array should only contain versions which should be kept
+ foreach ($versions as $version) {
+ $this->assertEquals("keep", $version['path']);
+ }
+
+ }
+
+ public function versionsProvider() {
+ return array(
+ // first set of versions uniformly distributed versions
+ array(
+ array(
+ // first slice (10sec) keep one version every 2 seconds
+ array("version" => 4999999, "path" => "keep", "size" => 1),
+ array("version" => 4999998, "path" => "delete", "size" => 1),
+ array("version" => 4999997, "path" => "keep", "size" => 1),
+ array("version" => 4999995, "path" => "keep", "size" => 1),
+ array("version" => 4999994, "path" => "delete", "size" => 1),
+ //next slice (60sec) starts at 4999990 keep one version every 10 secons
+ array("version" => 4999988, "path" => "keep", "size" => 1),
+ array("version" => 4999978, "path" => "keep", "size" => 1),
+ array("version" => 4999975, "path" => "delete", "size" => 1),
+ array("version" => 4999972, "path" => "delete", "size" => 1),
+ array("version" => 4999967, "path" => "keep", "size" => 1),
+ array("version" => 4999958, "path" => "delete", "size" => 1),
+ array("version" => 4999957, "path" => "keep", "size" => 1),
+ //next slice (3600sec) start at 4999940 keep one version every 60 seconds
+ array("version" => 4999900, "path" => "keep", "size" => 1),
+ array("version" => 4999841, "path" => "delete", "size" => 1),
+ array("version" => 4999840, "path" => "keep", "size" => 1),
+ array("version" => 4999780, "path" => "keep", "size" => 1),
+ array("version" => 4996401, "path" => "keep", "size" => 1),
+ // next slice (86400sec) start at 4996400 keep one version every 3600 seconds
+ array("version" => 4996350, "path" => "delete", "size" => 1),
+ array("version" => 4992800, "path" => "keep", "size" => 1),
+ array("version" => 4989800, "path" => "delete", "size" => 1),
+ array("version" => 4989700, "path" => "delete", "size" => 1),
+ array("version" => 4989200, "path" => "keep", "size" => 1),
+ // next slice (2592000sec) start at 4913600 keep one version every 86400 seconds
+ array("version" => 4913600, "path" => "keep", "size" => 1),
+ array("version" => 4852800, "path" => "delete", "size" => 1),
+ array("version" => 4827201, "path" => "delete", "size" => 1),
+ array("version" => 4827200, "path" => "keep", "size" => 1),
+ array("version" => 4777201, "path" => "delete", "size" => 1),
+ array("version" => 4777501, "path" => "delete", "size" => 1),
+ array("version" => 4740000, "path" => "keep", "size" => 1),
+ // final slice starts at 2408000 keep one version every 604800 secons
+ array("version" => 2408000, "path" => "keep", "size" => 1),
+ array("version" => 1803201, "path" => "delete", "size" => 1),
+ array("version" => 1803200, "path" => "keep", "size" => 1),
+ array("version" => 1800199, "path" => "delete", "size" => 1),
+ array("version" => 1800100, "path" => "delete", "size" => 1),
+ array("version" => 1198300, "path" => "keep", "size" => 1),
+ ),
+ 16 // size of all deleted files (every file has the size 1)
+ ),
+ // second set of versions, here we have only really old versions
+ array(
+ array(
+ // first slice (10sec) keep one version every 2 seconds
+ // next slice (60sec) starts at 4999990 keep one version every 10 secons
+ // next slice (3600sec) start at 4999940 keep one version every 60 seconds
+ // next slice (86400sec) start at 4996400 keep one version every 3600 seconds
+ array("version" => 4996400, "path" => "keep", "size" => 1),
+ array("version" => 4996350, "path" => "delete", "size" => 1),
+ array("version" => 4996350, "path" => "delete", "size" => 1),
+ array("version" => 4992800, "path" => "keep", "size" => 1),
+ array("version" => 4989800, "path" => "delete", "size" => 1),
+ array("version" => 4989700, "path" => "delete", "size" => 1),
+ array("version" => 4989200, "path" => "keep", "size" => 1),
+ // next slice (2592000sec) start at 4913600 keep one version every 86400 seconds
+ array("version" => 4913600, "path" => "keep", "size" => 1),
+ array("version" => 4852800, "path" => "delete", "size" => 1),
+ array("version" => 4827201, "path" => "delete", "size" => 1),
+ array("version" => 4827200, "path" => "keep", "size" => 1),
+ array("version" => 4777201, "path" => "delete", "size" => 1),
+ array("version" => 4777501, "path" => "delete", "size" => 1),
+ array("version" => 4740000, "path" => "keep", "size" => 1),
+ // final slice starts at 2408000 keep one version every 604800 secons
+ array("version" => 2408000, "path" => "keep", "size" => 1),
+ array("version" => 1803201, "path" => "delete", "size" => 1),
+ array("version" => 1803200, "path" => "keep", "size" => 1),
+ array("version" => 1800199, "path" => "delete", "size" => 1),
+ array("version" => 1800100, "path" => "delete", "size" => 1),
+ array("version" => 1198300, "path" => "keep", "size" => 1),
+ ),
+ 11 // size of all deleted files (every file has the size 1)
+ ),
+ // third set of versions, with some gaps inbetween
+ array(
+ array(
+ // first slice (10sec) keep one version every 2 seconds
+ array("version" => 4999999, "path" => "keep", "size" => 1),
+ array("version" => 4999998, "path" => "delete", "size" => 1),
+ array("version" => 4999997, "path" => "keep", "size" => 1),
+ array("version" => 4999995, "path" => "keep", "size" => 1),
+ array("version" => 4999994, "path" => "delete", "size" => 1),
+ //next slice (60sec) starts at 4999990 keep one version every 10 secons
+ array("version" => 4999988, "path" => "keep", "size" => 1),
+ array("version" => 4999978, "path" => "keep", "size" => 1),
+ //next slice (3600sec) start at 4999940 keep one version every 60 seconds
+ // next slice (86400sec) start at 4996400 keep one version every 3600 seconds
+ array("version" => 4989200, "path" => "keep", "size" => 1),
+ // next slice (2592000sec) start at 4913600 keep one version every 86400 seconds
+ array("version" => 4913600, "path" => "keep", "size" => 1),
+ array("version" => 4852800, "path" => "delete", "size" => 1),
+ array("version" => 4827201, "path" => "delete", "size" => 1),
+ array("version" => 4827200, "path" => "keep", "size" => 1),
+ array("version" => 4777201, "path" => "delete", "size" => 1),
+ array("version" => 4777501, "path" => "delete", "size" => 1),
+ array("version" => 4740000, "path" => "keep", "size" => 1),
+ // final slice starts at 2408000 keep one version every 604800 secons
+ array("version" => 2408000, "path" => "keep", "size" => 1),
+ array("version" => 1803201, "path" => "delete", "size" => 1),
+ array("version" => 1803200, "path" => "keep", "size" => 1),
+ array("version" => 1800199, "path" => "delete", "size" => 1),
+ array("version" => 1800100, "path" => "delete", "size" => 1),
+ array("version" => 1198300, "path" => "keep", "size" => 1),
+ ),
+ 9 // size of all deleted files (every file has the size 1)
+ ),
+
+ );
+ }
+
+}
+
+// extend the original class to make it possible to test protected methods
+class VersionStorageToTest extends \OCA\Files_Versions\Storage {
+
+ public function callProtectedGetExpireList($time, $versions) {
+ return self::getExpireList($time, $versions);
+
+ }
+}
diff --git a/apps/user_ldap/lib/helper.php b/apps/user_ldap/lib/helper.php
index 09f646921e3..9727d847d27 100644
--- a/apps/user_ldap/lib/helper.php
+++ b/apps/user_ldap/lib/helper.php
@@ -48,18 +48,25 @@ class Helper {
static public function getServerConfigurationPrefixes($activeConfigurations = false) {
$referenceConfigkey = 'ldap_configuration_active';
- $query = '
+ $sql = '
SELECT DISTINCT `configkey`
FROM `*PREFIX*appconfig`
WHERE `appid` = \'user_ldap\'
AND `configkey` LIKE ?
';
+
if($activeConfigurations) {
- $query .= ' AND `configvalue` = \'1\'';
+ if (\OC_Config::getValue( 'dbtype', 'sqlite' ) === 'oci') {
+ //FIXME oracle hack: need to explicitly cast CLOB to CHAR for comparison
+ $sql .= ' AND to_char(`configvalue`)=\'1\'';
+ } else {
+ $sql .= ' AND `configvalue` = \'1\'';
+ }
}
- $query = \OCP\DB::prepare($query);
- $serverConfigs = $query->execute(array('%'.$referenceConfigkey))->fetchAll();
+ $stmt = \OCP\DB::prepare($sql);
+
+ $serverConfigs = $stmt->execute(array('%'.$referenceConfigkey))->fetchAll();
$prefixes = array();
foreach($serverConfigs as $serverConfig) {