code: def add_tasks(self, pcs_files, dirname=''):
          '''建立批量下载任务, 包括目录'''
          def on_list_dir(info, error=None):
              path, pcs_files = info
              if error or not pcs_files:
                  dialog = Gtk.MessageDialog(self.app.window,
                          Gtk.DialogFlags.MODAL,
                          Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE,
                          _('Failed to scan folder to download'))
                  dialog.format_secondary_text(
                          _('Please download {0} again').format(path))
                  dialog.run()
                  dialog.destroy()
                  return
              self.add_tasks(pcs_files, dirname)
  
          self.check_first()
          for pcs_file in pcs_files:
              if pcs_file['isdir']:
                  gutil.async_call(pcs.list_dir_all, self.app.cookie,
                                   self.app.tokens, pcs_file['path'],
                                   callback=on_list_dir)
              else:
                  self.add_task(pcs_file, dirname)
          self.check_commit(force=Truef add_tasks(self, pcs_files, dirname=''):
          '''建立批量下载任务, 包括目录'''
          def on_list_dir(info, error=None):
              path, pcs_files = info
              if error or not pcs_files:
                  dialog = Gtk.MessageDialog(self.app.window,
                          Gtk.DialogFlags.MODAL,
                          Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE,
                          _('Failed to scan folder to download'))
                  dialog.format_secondary_text(
                          _('Please download {0} again').format(path))
                  dialog.run()
                  dialog.destroy()
                  return
              self.add_tasks(pcs_files, dirname)
  
          self.check_first()
          for pcs_file in pcs_files:
              if pcs_file['isdir']:
                  gutil.async_call(pcs.list_dir_all, self.app.cookie,
                                   self.app.tokens, pcs_file['path'],
                                   callback=on_list_dir)
              else:
                  self.add_task(pcs_file, dirname)
          self.check_commit(force=True)
docs: 建立批量下载任务, 包括目录