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/>.
from Plugins.SystemPlugins.CacheCockpit.FileManager import FileManager
from Plugins.SystemPlugins.MountCockpit.MountCockpit import MountCockpit
from .Debug import logger
from .FileUtils import deleteDirectory, createDirectory, writeFile
from .FileManagerUtils import FILE_OP_COPY
from .FileChecks import FileChecks
class Test(FileChecks):
def __init__(self, _session):
logger.info("...")
FileChecks.__init__(self)
self.home_dir = MountCockpit.getInstance().getHomeDir("MVC")
mounted_bookmarks = MountCockpit.getInstance().getMountedBookmarks("MVC")
self.source = ""
if len(mounted_bookmarks) >= 1:
self.source = mounted_bookmarks[0]
self.file_manager = FileManager.getInstance("MVC")
def start(self, index, callback):
self.index = index
self.callback = callback
if self.source:
deleteDirectory(self.source + "/test2")
deleteDirectory(self.source + "/test1/test11/test111")
createDirectory(self.source + "/test2")
createDirectory(self.source + "/test1/test11/test111")
writeFile(self.source + "/test1/file1.ts", "test")
writeFile(self.source + "/test1/test11/file11.ts", "test")
writeFile(self.source + "/test1/test11/file12.ts", "test")
writeFile(self.source + "/test1/test11/test111/file111.ts", "test")
self.file_manager.clearDatabase()
self.file_manager.onDatabaseLoaded(self.databaseLoaded)
self.file_manager.loadDatabase()
else:
self.callback(self.index, False)
def databaseLoaded(self):
logger.info("...")
self.file_manager.execFileOp(FILE_OP_COPY, self.source + "/test1", self.source + "/test2", self.copyCallback)
def copyCallback(self, _file_op, _path, _target_dir, error):
success = error == 0
success = success and (
self.doesExist(self.source + "/test2")
and self.doesExist(self.source + "/test2/test1")
and self.doesExist(self.source + "/test2/test1/test11")
and self.doesExist(self.source + "/test2/test1/test11/test111")
and self.doesExist(self.source + "/test2/test1/file1.ts")
and self.doesExist(self.source + "/test2/test1/test11/file11.ts")
and self.doesExist(self.source + "/test2/test1/test11/file12.ts")
and self.doesExist(self.source + "/test2/test1/test11/test111/file111.ts")
)
success = success and (
self.doesExist(self.source + "/test1")
and self.doesExist(self.source + "/test1/test11")
and self.doesExist(self.source + "/test1/test11/test111")
and self.doesExist(self.source + "/test1/file1.ts")
and self.doesExist(self.source + "/test1/test11/file11.ts")
and self.doesExist(self.source + "/test1/test11/file12.ts")
and self.doesExist(self.source + "/test1/test11/test111/file111.ts")
)
self.callback(self.index, success)