是否可以在应用引擎 blobstore 中查找和删除孤立的 blob? [英] Is it possible to find and delete orphaned blobs in the app engine blobstore?

查看:32
本文介绍了是否可以在应用引擎 blobstore 中查找和删除孤立的 blob?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 python api,并在测试期间创建了一些孤立的 blob.

I'm using the python api and have created a few orphaned blobs during testing.

由于仪表板中的错误,我目前无法删除这些,无论如何,我希望能够以编程方式执行此操作,因为一旦实体数量增加,手动执行此操作将不可行

Because of a bug in the dashboard, I can't currently delete these, and in any case going forward I would like to be able to do this programmatically since it will be unfeasible to do it manually once the number of entities goes up.

推荐答案

如果您的 BlobReferenceProperty 字段已编入索引,那么是的,很有可能.

If your BlobReferenceProperty field is indexed, then yes, it's quite possible.

BlobInfo 类提供与一个常规模型,所以你可以这样做:

The BlobInfo class provides the same set of fields as a regular model, so you can do it something like this:

blobs = BlobInfo.all().fetch(500)
for blob in blobs:
  if not MyModel.all().filter("blob_ref =", blob.key()).count(1):
    blob.delete()

如果您有多个 blob,您可能想使用最近减少的 mapreduce API.

If you have more than a few blobs, you probably want to reimplement this using the recently reduced mapreduce API.

这篇关于是否可以在应用引擎 blobstore 中查找和删除孤立的 blob?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆