content tree provider test
This commit is contained in:
parent
a7998082a7
commit
083a177613
9 changed files with 62 additions and 19 deletions
|
@ -1,17 +1,45 @@
|
|||
package net.schowek.nextclouddlna.nextcloud.content
|
||||
|
||||
import net.schowek.nextclouddlna.nextcloud.db.AppConfigId
|
||||
import net.schowek.nextclouddlna.nextcloud.db.AppConfigRepository
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import spock.lang.Unroll
|
||||
import support.IntegrationSpecification
|
||||
|
||||
@Unroll
|
||||
class ContentTreeProviderIntTest extends IntegrationSpecification {
|
||||
@Autowired
|
||||
ContentTreeProvider contentTreeProvider
|
||||
@Autowired
|
||||
AppConfigRepository appConfigRepository
|
||||
|
||||
def "should foo"() {
|
||||
def "should create content tree including the group folder"() {
|
||||
when:
|
||||
def result = contentTreeProvider.getItem("19")
|
||||
contentTreeProvider.rebuildTree(true)
|
||||
|
||||
then:
|
||||
result.id == 19
|
||||
def root = contentTreeProvider.getNode("0")
|
||||
with(root) {
|
||||
nodes.size() == 3
|
||||
nodes[0].name == "johndoe"
|
||||
nodes[1].name == "janedoe"
|
||||
nodes[2].name == "family folder"
|
||||
}
|
||||
}
|
||||
|
||||
def "should create content tree without the group folder"() {
|
||||
given:
|
||||
appConfigRepository.deleteById(new AppConfigId("groupfolders", "enabled"))
|
||||
|
||||
when:
|
||||
contentTreeProvider.rebuildTree(true)
|
||||
|
||||
then:
|
||||
def root = contentTreeProvider.getNode("0")
|
||||
with(root) {
|
||||
nodes.size() == 2
|
||||
nodes[0].name == "johndoe"
|
||||
nodes[1].name == "janedoe"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,22 +6,33 @@ INSERT INTO `oc_appconfig` VALUES
|
|||
|
||||
INSERT INTO `oc_filecache` VALUES
|
||||
(1,1,'','d41d8cd98f00b204e9800998ecf8427e',-1,'',2,1,5341566992,1696704138,1696613362,0,0,'',23,''),
|
||||
(2,1,'files','45b963397aa40d4a0063e0d85e4fe7a1',1,'files',2,1,5341560694,1696704138,1696704138,0,0,'',31,''),
|
||||
(3,2,'','d41d8cd98f00b204e9800998ecf8427e',-1,'',2,1,13286908,1696702221,1696695204,0,0,'',23,''),
|
||||
(4,2,'appdata_integration','bed7fa8a60170b5d88c9da5e69eaeb5a',3,'appdata_integration',2,1,10274496,1695737790,1695737790,0,0,'',31,''),
|
||||
(384,3,'','d41d8cd98f00b204e9800998ecf8427e',-1,'',2,1,37549364,1696702111,1695740236,0,0,'',23,''),
|
||||
|
||||
(2,1,'files','45b963397aa40d4a0063e0d85e4fe7a1',1,'files',2,1,5341560694,1696704138,1696704138,0,0,'',31,''),
|
||||
(13,1,'files/Nextcloud intro.mp4','e4919345bcc87d4585a5525daaad99c0',2,'Nextcloud intro.mp4',9,8,3963036,1695737656,1695737656,0,0,'',27,''),
|
||||
(14,1,'files/Nextcloud.png','',2,'Nextcloud.png',11,10,50598,1695737656,1695737656,0,0,'',27,''),
|
||||
(15,1,'files/Photos','d01bb67e7b71dd49fd06bad922f521c9',2,'Photos',2,1,5656462,1695737827,1695737658,0,0,'',31,''),
|
||||
(16,1,'files/Photos/Birdie.jpg','cd31c7af3a0ec6e15782b5edd2774549',15,'Birdie.jpg',12,10,593508,1695737656,1695737656,0,0,'',27,''),
|
||||
(17,1,'files/Photos/Frog.jpg','d6219add1a9129ed0c1513af985e2081',15,'Frog.jpg',12,10,457744,1695737656,1695737656,0,0,'',27,''),
|
||||
(18,1,'files/Photos/Gorilla.jpg','6d5f5956d8ff76a5f290cebb56402789',15,'Gorilla.jpg',12,10,474653,1695737656,1695737656,0,0,'',27,''),
|
||||
(19,1,'files/Photos/Library.jpg','0b785d02a19fc00979f82f6b54a05805',15,'Library.jpg',12,10,2170375,1695737657,1695737657,0,0,'',27,''),
|
||||
(20,1,'files/Photos/Nextcloud community.jpg','b9b3caef83a2a1c20354b98df6bcd9d0',15,'Nextcloud community.jpg',12,10,797325,1695737657,1695737657,0,0,
|
||||
'',27,''),
|
||||
(22,1,'files/Photos/Steps.jpg','7b2ca8d05bbad97e00cbf5833d43e912',15,'Steps.jpg',12,10,567689,1695737658,1695737658,0,0,'',27,''),
|
||||
(23,1,'files/Photos/Toucan.jpg','681d1e78f46a233e12ecfa722cbc2aef',15,'Toucan.jpg',12,10,167989,1695737658,1695737658,0,0,'',27,''),
|
||||
(24,1,'files/Photos/Vineyard.jpg','14e5f2670b0817614acd52269d971db8',15,'Vineyard.jpg',12,10,427030,1695737658,1695737658,0,0,'',27,''),
|
||||
(69,2,'appdata_integration/preview','e771733d5f59ead277f502588282d693',4,'preview',2,1,5153144,1695738765,1695738765,0,0,'',31,'');
|
||||
(15,1,'files/photos','d01bb67e7b71dd49fd06bad922f521c9',2,'photos',2,1,5656462,1695737827,1695737658,0,0,'',31,''),
|
||||
(16,1,'files/photos/Birdie.jpg','cd31c7af3a0ec6e15782b5edd2774549',15,'Birdie.jpg',12,10,593508,1695737656,1695737656,0,0,'',27,''),
|
||||
(17,1,'files/photos/Frog.jpg','d6219add1a9129ed0c1513af985e2081',15,'Frog.jpg',12,10,457744,1695737656,1695737656,0,0,'',27,''),
|
||||
(18,1,'files/photos/Gorilla.jpg','6d5f5956d8ff76a5f290cebb56402789',15,'Gorilla.jpg',12,10,474653,1695737656,1695737656,0,0,'',27,''),
|
||||
(19,1,'files/photos/Library.jpg','0b785d02a19fc00979f82f6b54a05805',15,'Library.jpg',12,10,2170375,1695737657,1695737657,0,0,'',27,''),
|
||||
|
||||
(387,3,'files','45b963397aa40d4a0063e0d85e4fe7a1',384,'files',2,1,9670097,1695740237,1695740237,0,0,'',31,''),
|
||||
(396,3,'files/pictures','d01bb67e7b71dd49fd06bad922f521c9',387,'pictures',2,1,5656463,1695740165,1695740165,0,0,'',31,''),
|
||||
(397,3,'files/pictures/Steps.jpg','7b2ca8d05bbad97e00cbf5833d43e912',396,'Steps.jpg',12,10,567689,1695737658,1695737658,0,0,'',27,''),
|
||||
(398,3,'files/pictures/Toucan.jpg','681d1e78f46a233e12ecfa722cbc2aef',396,'Toucan.jpg',12,10,167989,1695737658,1695737658,0,0,'',27,''),
|
||||
(399,3,'files/pictures/Vineyard.jpg','14e5f2670b0817614acd52269d971db8',396,'Vineyard.jpg',12,10,427030,1695737658,1695737658,0,0,'',27,''),
|
||||
|
||||
(4,2,'appdata_integration','bed7fa8a60170b5d88c9da5e69eaeb5a',3,'appdata_integration',2,1,10274496,1695737790,1695737790,0,0,'',31,''),
|
||||
(69,2,'appdata_integration/preview','e771733d5f59ead277f502588282d693',4,'preview',2,1,5153144,1695738765,1695738765,0,0,'',31,''),
|
||||
|
||||
(584,2,'__groupfolders','29ff0edf73a32cb03e437d88fd049245',3,'__groupfolders',2,1,3012412,1696702221,1696702221,0,0,'',31,''),
|
||||
(586,2,'__groupfolders/1','e46cc72327dfc3ccaf32f0a167e6c6d1',584,'1',2,1,3012412,1696695701,1696695701,0,0,'',31,''),
|
||||
(587,2,'__groupfolders/Nextcloud community.jpg','b9b3caef83a2a1c20354b98df6bcd9d0',586,'Nextcloud community.jpg',12,10,797325,1695737657,1695737657,0,0,
|
||||
'',27,'');
|
||||
|
||||
|
||||
|
||||
INSERT INTO `oc_group_folders` VALUES
|
||||
(1,'family folder',-3,0);
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 779 KiB |
Binary file not shown.
After Width: | Height: | Size: 554 KiB |
Binary file not shown.
After Width: | Height: | Size: 164 KiB |
Binary file not shown.
After Width: | Height: | Size: 417 KiB |
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
|
@ -15,9 +15,9 @@ class NextcloudConfigDiscovery(
|
|||
) {
|
||||
val appDataDir: String = findAppDataDir()
|
||||
val nextcloudDir: File get() = nextcloudDirProvider.nextcloudDir
|
||||
val supportsGroupFolders: Boolean = checkGroupFoldersSupport()
|
||||
val supportsGroupFolders: Boolean get() = checkGroupFoldersSupport()
|
||||
|
||||
private fun checkGroupFoldersSupport(): Boolean {
|
||||
fun checkGroupFoldersSupport(): Boolean {
|
||||
return "yes" == appConfigRepository.getValue("groupfolders", "enabled")
|
||||
}
|
||||
|
||||
|
|
|
@ -18,9 +18,13 @@ class ContentTreeProvider(
|
|||
|
||||
@Scheduled(fixedDelay = REBUILD_TREE_DELAY_IN_MS, initialDelay = REBUILD_TREE_INIT_DELAY_IN_MS)
|
||||
final fun rebuildTree() {
|
||||
rebuildTree(false)
|
||||
}
|
||||
|
||||
final fun rebuildTree(force: Boolean) {
|
||||
val maxMtime: Long = nextcloudDB.maxMtime()
|
||||
val now = Instant.now().epochSecond
|
||||
if (lastMTime < maxMtime || lastMTime + MAX_REBUILD_OFFSET_IN_S > now) {
|
||||
if (force || lastMTime < maxMtime || lastMTime + MAX_REBUILD_OFFSET_IN_S > now) {
|
||||
logger.info("ContentTree seems to be outdated - Loading...")
|
||||
this.tree = buildContentTree()
|
||||
lastMTime = maxMtime
|
||||
|
|
Loading…
Reference in a new issue