Repository URL to install this package:
#!/usr/bin/python
# coding=utf-8
#
# Copyright (C) 2018-2025 by dream-alpha
#
# In case of reuse of this source code please do not remove this copyright.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# For more information on the GNU General Public License see:
# <http://www.gnu.org/licenses/>.
import os
from Plugins.SystemPlugins.CacheCockpit.FileManager import FileManager
from Plugins.SystemPlugins.MountCockpit.MountCockpit import MountCockpit
from .Debug import logger
from .TestCockpitUtils import countDiskFiles
class Test():
def __init__(self, _session):
logger.info("...")
self.file_manager = FileManager.getInstance("MVC")
def start(self, index, callback):
self.index = index
self.callback = callback
bookmarks = MountCockpit.getInstance().getMountedBookmarks("MVC")
for bookmark in bookmarks:
if os.path.exists(bookmark + "/trashcan"):
os.system("rm -rf %s" % bookmark + "/trashcan/*")
self.files_count, self.dirs_count, self.dirs_list = countDiskFiles(bookmarks)
self.file_manager.clearDatabase()
self.file_manager.onDatabaseLoaded(self.databaseLoaded)
self.file_manager.loadDatabase()
def databaseLoaded(self):
logger.info("...")
self.home_dir = MountCockpit.getInstance().getHomeDir("MVC")
count, _size = self.file_manager.getCountSize(self.home_dir)
logger.debug("self.files_count: %s, cache count: %s", count, self.files_count)
success = self.files_count == count
if success:
self.test1()
else:
self.callback(self.index, success)
def test1(self):
file_list = self.file_manager.getFileList(self.home_dir, True)
dir_list = self.file_manager.getDirListAll(self.home_dir, True)
logger.debug("len(file_list): %s, files_count: %s", len(file_list), self.files_count)
logger.debug("len(dir_list): %s, dirs_count: %s", len(dir_list), self.dirs_count)
success = self.files_count == len(file_list) and self.dirs_count == len(dir_list)
for adir in dir_list:
logger.debug("dir1: %s", adir)
for adir in self.dirs_list:
logger.debug("dir2: %s", adir)
self.callback(self.index, success)