Yes, I messaged you in IRC to similar effect :)


On Tue, Apr 22, 2014 at 4:57 PM, Mike Rhodes <notifications@github.com>wrote:

> In src/main/java/com/cloudant/sync/datastore/AttachmentManager.java:
>
> > +        for (String attachmentName : attachmentNames) {
> > +            // first see if it exists
> > +            SavedAttachment a = (SavedAttachment) this.getAttachment(rev, attachmentName);
> > +            if (a == null) {
> > +                Log.w(LOG_TAG, "Could not find attachment to delete from database with filename = "+attachmentName+", sequence = "+rev.getSequence());
> > +                continue;
> > +            }
> > +            // get the file in blob store
> > +            File f = this.fileFromKey(a.key);
> > +            boolean rowDeleted = datastore.getSQLDatabase().delete("attachments", " filename = ? and sequence = ? ",
> > +                    new String[]{attachmentName, String.valueOf(rev.getSequence())}) == 1;
> > +            if (!rowDeleted) {
> > +                Log.w(LOG_TAG, "Could not delete attachment from database with filename = "+attachmentName+", sequence = "+rev.getSequence());
> > +            }
> > +            // delete attachments from blob store
> > +            boolean fileDeleted = f.delete();
>
> TouchDB has a simple garbage collection method which finds files not
> referenced in the attachments table any more and removes them. I'd be
> inclined to go down that route.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/cloudant/sync-android/pull/20/files#r11860486>
> .
>