async def uploadFolder( self, sourceFolder: AsyncPath, *, gid: Optional[str] = None, parent_id: Optional[str] = None, msg: Optional[pyrogram.types.Message] = None ) -> AsyncIterator[asyncio.Task[None]]: async for content in sourceFolder.iterdir(): if await content.is_dir(): childFolder = await self.createFolder(content.name, parent_id) async for task in self.uploadFolder(content, gid=gid, parent_id=childFolder, msg=msg): yield task elif await content.is_file(): file = util.File(content) content = await self.uploadFile(file, parent_id, msg) if isinstance(content, str): # Skip because file size is 0 continue yield self.bot.loop.create_task(file.progress(update=False), name=gid) await asyncio.sleep(0.5) else: raise ValueError(f"{content} is not a file or folder")
async def extract_backups(path: Path): await TARGET_DIR.mkdir(exist_ok=True, parents=True) await asyncio.wait([extract(p) async for p in path.iterdir()])