def copyRecentFilesIntoCache(self, transfer_q: MaxPrioQueue): print(Col.b('Transfering files...')) while not transfer_q.empty() and not self.disk.isFull( use_threshold=True): timestamp, (inode, file_size) = transfer_q.pop_nowait() path = self.vfs._inode_path_map[inode].src # skip symbolic links for now if os.path.islink(path): continue try: dest = self.disk.cp2Cache(path) except NotEnoughSpaceError: # filter the Queue purged_list = MaxPrioQueue() while not transfer_q.empty(): timestamp_i, (inode_i, size_i) = transfer_q.pop_nowait() if size_i < file_size: purged_list.push_nowait( (timestamp_i, (inode_i, size_i))) transfer_q = purged_list # print summary diskUsage, usedCache, maxCache = self.disk.getCurrentStatus() diskUsage = Col.by(f'{diskUsage:.8f}%') usedCache = Col.by(f'{Col.BY}{formatByteSize(usedCache)} ') maxCache = Col.by(f'{formatByteSize(maxCache)} ') copySummary = \ Col.bw(f'Finished transfering {self.disk.in_cache.qsize()} elements.\nCache is now {diskUsage} ') + Col.bw( 'full') + \ Col.bw(f" (used: {usedCache}") + Col.bw(f" / {maxCache}") + Col.bw(")") print(copySummary)
def printSummary(self): diskUsage, usedCache, maxCache = self.getCurrentStatus() diskUsage = Col.by(f'{diskUsage:.8f}%') usedCache = Col.by(f'{Col.BY}{formatByteSize(usedCache)} ') maxCache = Col.by(f'{formatByteSize(maxCache)} ') copySummary = \ Col.bw( f'Cache is currently storing {self.in_cache.qsize()} elements and is {diskUsage} ') + Col.bw( 'full\n') + \ Col.bw(f" (used: {usedCache}") + Col.bw(f" / {maxCache}") + Col.bw(")") print(copySummary)