OC.L10N.register( "files_external", { "External storages" : "Спољашње складиште", "Personal" : "Лично", "System" : "Систем", "Grant access" : "Одобри приступ", "Error configuring OAuth1" : "Грешка у подешавању OAuth1", "Please provide a valid app key and secret." : "Наведите исправан апликативни кључ и тајну.", "Error configuring OAuth2" : "Грешка у подешавању OAuth2", "Generate keys" : "Генериши кључеве", "Error generating key pair" : "Грешка при генерисању пара кључева", "All users. Type to select user or group." : "Сви корисници. Куцајте за избор корисника или групе.", "(group)" : "(група)", "Compatibility with Mac NFD encoding (slow)" : "Компатибилност са NFD кодирањем (споро)", "Admin defined" : "Дефинисао администратор", "Are you sure you want to delete this external storage" : "Да ли стварно желите да обришете ово спољашње складиште?", "Delete storage?" : "Обриши складиште?", "Saved" : "Сачувано", "Saving..." : "Чувам...", "Save" : "Сачувај", "Empty response from the server" : "Празан одговор са сервера", "Couldn't access. Please log out and in again to activate this mount point" : "Не могу да приступим. Одјавите се и пријавите поново да активирате ову тачку монтирања", "Couldn't get the information from the remote server: {code} {type}" : "Не могу да дохватим информације са удаљеног сервера: {code} {type}", "Couldn't get the list of external mount points: {type}" : "Не могу да дохватим листу спољних тачака монтирања: {type}", "There was an error with message: " : "Догодила се грешка уз поруку:", "External mount error" : "Спољна грешка при монтирању", "external-storage" : "спољашње-складиште", "Couldn't fetch list of Windows network drive mount points: Empty response from server" : "Не могу да добавим листу тачака монтирања Виндоуз мрежних дискова: празан одговор са сервера", "Some of the configured external mount points are not connected. Please click on the red row(s) for more information" : "Неке од конфигурисаних спољашњих тачака монтирања нису повезане. Кликните на црвени ред(ове) за више информација", "Please enter the credentials for the {mount} mount" : "Унесите акредитиве за {mount} тачку монтирања", "Username" : "Корисничко име", "Password" : "Лозинка", "Credentials saved" : "Акредитиви снимљени", "Credentials saving failed" : "Снимање акредитива није успело", "Credentials required" : "Потребни акредитиви", "Storage with ID \"%d\" not found" : "Складиште са идентификацијом \"%d\" није пронађено", "Invalid backend or authentication mechanism class" : "Неисправан позадински механизам или начин провере идентитета", "Invalid mount point" : "Неисправна тачка монтирања", "Objectstore forbidden" : "Забрањен приступ", "Invalid storage backend \"%s\"" : "Неисправна позадина складишта „%s“", "Not permitted to use backend \"%s\"" : "Недозвољени коришћење позадине \"%s\"", "Not permitted to use authentication mechanism \"%s\"" : "Недозвољено коришћене провере идентитета користећи \"%s\"", "Unsatisfied backend parameters" : "Недостају параметри за позадински механизам", "Unsatisfied authentication mechanism parameters" : "Недостају параметри за механизам провере идентитета", "Insufficient data: %s" : "Недеовољно података: %s", "%s" : "%s", "Storage with ID \"%d\" is not user editable" : "Корисник не може да мења складиште са идентификацијом \"%d\"", "Access key" : "Кључ за приступ", "Secret key" : "Тајни кључ ", "Builtin" : "Уграђено", "None" : "Ништа", "OAuth1" : "OAuth1", "App key" : "Кључ апликације", "App secret" : "Тајна апликације", "OAuth2" : "OAuth2", "Client ID" : "ИД клијента", "Client secret" : "Тајна клијента", "OpenStack v2" : "OpenStack v2", "Tenant name" : "Име OpenStack тенанта", "Identity endpoint URL" : "УРЛ идентитета", "OpenStack v3" : "OpenStack v3", "Domain" : "Домен", "Rackspace" : "Rackspace", "API key" : "API кључ", "Global credentials" : "Глобални акредитиви", "Log-in credentials, save in database" : "Акредитиви за пријаву, чувани у бази", "Username and password" : "Корисничко име и лозинка", "Log-in credentials, save in session" : "Акредитиви за пријаву, чувани у сесији", "User entered, store in database" : "Корисник уноси, чува се у бази", "RSA public key" : "RSA јавни кључ", "Public key" : "Јавни кључ", "Amazon S3" : "Amazon S3", "Bucket" : "Канта", "Hostname" : "Име домаћина", "Port" : "Порт", "Region" : "Регија", "Enable SSL" : "Омогући ССЛ", "Enable Path Style" : "Омогући стил путање", "Legacy (v2) authentication" : "Стара (v2) провера идентитета", "WebDAV" : "ВебДАВ", "URL" : "УРЛ", "Remote subfolder" : "Удаљена потфасцикла", "Secure https://" : "Сигурни https://", "FTP" : "FTP", "Host" : "Домаћин", "Secure ftps://" : "Сигурни ftps://", "Local" : "локална", "Location" : "Локација", "Nextcloud" : "Некстклауд", "SFTP" : "SFTP", "Root" : "Корен", "SFTP with secret key login" : "SFTP са пријавом помоћу тајног кључа", "SMB / CIFS" : "SMB / CIFS", "Share" : "Дели", "SMB / CIFS using OC login" : "SMB / CIFS користећи Некстклауд пријаву", "Username as share" : "Корисничко име као дељење", "OpenStack Object Storage" : "OpenStack Object Storage", "Service name" : "Назив услуге", "Request timeout (seconds)" : "Време захтева истекло (секунде)", "The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "cURL подршка за PHP није омогућена или инсталирана. Монтирање %s није могуће. Затражите од вашег администратора система да је инсталира.", "The FTP support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "FTP подршка за PHP није омогућена или инсталирана. Монтирање %s није могуће. Затражите од вашег администратора система да је инсталира.", "\"%s\" is not installed. Mounting of %s is not possible. Please ask your system administrator to install it." : "„%s“ није инсталиран. Монтирање %s није могуће. Затражите од вашег администратора система да га инсталира.", "External storage support" : "Подршка за спољашње складиште", "No external storage configured or you don't have the permission to configure them" : "Нема конфигурисаних спољашњих складишта или немате потребне дозволе да их конфигуришете", "Name" : "Назив", "Storage type" : "Тип складишта", "Scope" : "Опсег", "Enable encryption" : "Укључи шифровање", "Enable previews" : "Укључи прегледе", "Enable sharing" : "Укључи дељење", "Check for changes" : "Проверавај за измене", "Never" : "никад", "Once every direct access" : "једном при сваком директном приступу", "Folder name" : "Назив фасцикле", "External storage" : "Спољашње складиште", "Authentication" : "Провера идентитета", "Configuration" : "Подешавање", "Available for" : "Доступно за", "Click to recheck the configuration" : "Кликните овде да поново проверите конфигурацију", "Add storage" : "Додај складиште", "Advanced settings" : "Напредне поставке", "Delete" : "Обриши", "Allow users to mount external storage" : "Дозволи корисницима да монтирају спољашња складишта", "Allow users to mount the following external storage" : "Дозволи корисницима да монтирају следећа спољашња складишта", "Fetching request tokens failed. Verify that your app key and secret are correct." : "Дохватање токена за захтеве није успело. Проверите да ли су апликативни кључ и тајна исправни.", "Fetching access tokens failed. Verify that your app key and secret are correct." : "Дохватање токена за приступ није успело. Проверите да ли су апликативни кључ и тајна исправни.", "Step 1 failed. Exception: %s" : "Корак 1 није успео. Грешка: %s", "Step 2 failed. Exception: %s" : "Корак 2 није успео. Грешка: %s", "Dropbox App Configuration" : "Dropbox конфигурација апликације", "Google Drive App Configuration" : "Google Drive конфигурација апликације", "OpenStack" : "OpenStack", "Dropbox" : "Dropbox", "Google Drive" : "Google Drive", "No external storage configured" : "Нема подешеног спољашњег складишта", "You can add external storages in the personal settings" : "Можете додати спољашња складишта у вашим личним подешавањима" }, "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);"); n'>authPropertyPromotion Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/files/cache/watcher.php
blob: 1920c2769079a37ac6b2c5e00916fa74c0eaa554 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
/**
 * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */

namespace Test\Files\Cache;

class Watcher extends \PHPUnit_Framework_TestCase {

	/**
	 * @var \OC\Files\Storage\Storage[] $storages;
	 */
	private $storages = array();

	public function setUp() {
		\OC\Files\Filesystem::clearMounts();
	}

	public function tearDown() {
		foreach ($this->storages as $storage) {
			$cache = $storage->getCache();
			$ids = $cache->getAll();
			$permissionsCache = $storage->getPermissionsCache();
			$permissionsCache->removeMultiple($ids, \OC_User::getUser());
			$cache->clear();
		}
	}

	/**
	 * @medium
	 */
	function testWatcher() {
		$storage = $this->getTestStorage();
		$cache = $storage->getCache();
		$updater = $storage->getWatcher();

		//set the mtime to the past so it can detect an mtime change
		$cache->put('', array('storage_mtime' => 10));

		$this->assertTrue($cache->inCache('folder/bar.txt'));
		$this->assertTrue($cache->inCache('folder/bar2.txt'));

		$this->assertFalse($cache->inCache('bar.test'));
		$storage->file_put_contents('bar.test', 'foo');
		$updater->checkUpdate('');
		$this->assertTrue($cache->inCache('bar.test'));
		$cachedData = $cache->get('bar.test');
		$this->assertEquals(3, $cachedData['size']);

		$cache->put('bar.test', array('storage_mtime' => 10));
		$storage->file_put_contents('bar.test', 'test data');

		// make sure that PHP can read the new size correctly
		clearstatcache();

		$updater->checkUpdate('bar.test');
		$cachedData = $cache->get('bar.test');
		$this->assertEquals(9, $cachedData['size']);

		$cache->put('folder', array('storage_mtime' => 10));

		$storage->unlink('folder/bar2.txt');
		$updater->checkUpdate('folder');

		$this->assertTrue($cache->inCache('folder/bar.txt'));
		$this->assertFalse($cache->inCache('folder/bar2.txt'));
	}

	/**
	 * @medium
	 */
	public function testFileToFolder() {
		$storage = $this->getTestStorage();
		$cache = $storage->getCache();
		$updater = $storage->getWatcher();

		//set the mtime to the past so it can detect an mtime change
		$cache->put('', array('storage_mtime' => 10));

		$storage->unlink('foo.txt');
		$storage->rename('folder', 'foo.txt');
		$updater->checkUpdate('');

		$entry = $cache->get('foo.txt');
		$this->assertEquals('httpd/unix-directory', $entry['mimetype']);
		$this->assertFalse($cache->inCache('folder'));
		$this->assertFalse($cache->inCache('folder/bar.txt'));

		$storage = $this->getTestStorage();
		$cache = $storage->getCache();
		$updater = $storage->getWatcher();

		//set the mtime to the past so it can detect an mtime change
		$cache->put('foo.txt', array('storage_mtime' => 10));

		$storage->unlink('foo.txt');
		$storage->rename('folder', 'foo.txt');
		$updater->checkUpdate('foo.txt');

		$entry = $cache->get('foo.txt');
		$this->assertEquals('httpd/unix-directory', $entry['mimetype']);
		$this->assertTrue($cache->inCache('foo.txt/bar.txt'));
	}

	/**
	 * @param bool $scan
	 * @return \OC\Files\Storage\Storage
	 */
	private function getTestStorage($scan = true) {
		$storage = new \OC\Files\Storage\Temporary(array());
		$textData = "dummy file data\n";
		$imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png');
		$storage->mkdir('folder');
		$storage->file_put_contents('foo.txt', $textData);
		$storage->file_put_contents('foo.png', $imgData);
		$storage->file_put_contents('folder/bar.txt', $textData);
		$storage->file_put_contents('folder/bar2.txt', $textData);

		if ($scan) {
			$scanner = $storage->getScanner();
			$scanner->scan('');
		}
		$this->storages[] = $storage;
		return $storage;
	}
}