code: def safe_extract_proto_from_ipfs(ipfs_client, ipfs_hash, protodir):
      
      spec_tar = get_from_ipfs_and_checkhash(ipfs_client, ipfs_hash)
      with tarfile.open(fileobj=io.BytesIO(spec_tar)) as f:
          for m in f.getmembers():
              if (os.path.dirname(m.name) != ""):
                  raise Exception("tarball has directories. We do not support it.")
              if (not m.isfile()):
                  raise Exception("tarball contains %s which is not a files"%m.name)
              fullname = os.path.join(protodir, m.name)
              if (os.path.exists(fullname)):
                  raise Exception("%s already exists."%fullname)
          # now it is safe to call extractall
          f.extractall(protodir)
docs: Tar files might be dangerous (see https://bugs.python.org/issue21109,
      and https://docs.python.org/3/library/tarfile.html, TarFile.extractall warning)
      we extract only simple files