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

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

问题描述

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

由于仪表板中存在一个错误,我目前无法删除这些,在任何情况下,我都希望能够以编程方式完成这项工作,因为一旦实体数量增加,手动执行操作将无法实现。

解决方案

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



BlobInfo 类提供了与常规模型相同的一组字段,因此您可以这样做: p>

  blobs = BlobInfo.all()。fetch(500)
blob中的blob:
if MyModel .all()。filter(blob_ref =,blob.key())。count(1):
blob.delete()

如果你有更多的斑点,你可能想用rec来重新实现自然减少了 mapreduce API


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.

解决方案

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

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()

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

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

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