Beispiel #1
0
    def deleteFile(self, request, context):
        FilePath = request.path
        # isFolder = request.isFolder
        msg0 = msg1 = 0
        listToDelete = []
        try:
            listToDelete = filetree.FileTree.getLeafNodes(FilePath)
        except:
            return MasterForClient_pb2.ACK(
                msg='Oops, no such directory or file', feedBack=False)

        msg0 = filetree.FileTree.removeNode(FilePath)
        filetree.FileTree.print_tree()
        if listToDelete:
            for fileName in listToDelete:
                msg2 = 0
                fileForFID = FileManager.sys.FindByFilenama(fileName)
                chunkList = fileForFID.getChunkList()
                for chunk in chunkList:
                    did = chunk.getDataserverID()
                    cid = chunk.getChunkId()
                    response = deleteChunkOnDataServer(ConnectDataServer(did),
                                                       cid)
                    if response.feedback:
                        msg2 += 1
                    Backup.BackupManager.insertDeleteTask(
                        chunk.getFileID(), cid)
                if msg2 == len(chunkList):
                    msg1 += 1
                else:
                    break
                FileManager.sys.DeleteFile(fileForFID.getFID())
        if msg0 and msg1 == len(listToDelete):
            return MasterForClient_pb2.ACK(msg='Successful!', feedBack=True)
        else:
            return MasterForClient_pb2.ACK(msg='Failed!', feedBack=False)
Beispiel #2
0
 def createFolder(self, request, context):
     destination = request.destination
     return MasterForClient_pb2.ACK(feedBack=filetree.FileTree.insertNode(
         destination, True),
                                    msg='dummy message')