~ubuntu-branches/ubuntu/vivid/swift/vivid-updates

« back to all changes in this revision

Viewing changes to swift/account/backend.py

  • Committer: Package Import Robot
  • Author(s): James Page, Chuck Short, James Page
  • Date: 2014-10-06 10:06:11 UTC
  • mfrom: (1.2.31)
  • Revision ID: package-import@ubuntu.com-20141006100611-wdzkkuoru7ubtlml
Tags: 2.1.0-0ubuntu1
[ Chuck Short ]
* debian/patches/fix-doc-no-network.patch: Refreshed.
* debian/control: Add python-oslosphinx as a build dependency.

[ James Page ]
* New upstream release for OpenStack Juno.
* d/copyright: Add linebreaks to fixup file-without-copyright-
  information warning.

Show diffs side-by-side

added added

removed removed

Lines of Context:
312
312
        """Only returns true if the status field is set to DELETED."""
313
313
        with self.get() as conn:
314
314
            row = conn.execute('''
315
 
                SELECT status
 
315
                SELECT put_timestamp, delete_timestamp, status
316
316
                FROM account_stat''').fetchone()
317
 
            return (row['status'] == "DELETED")
 
317
            return row['status'] == "DELETED" or (
 
318
                row['delete_timestamp'] > row['put_timestamp'])
318
319
 
319
320
    def get_policy_stats(self):
320
321
        """
453
454
        """
454
455
        def _really_merge_items(conn):
455
456
            max_rowid = -1
 
457
            curs = conn.cursor()
456
458
            for rec in item_list:
457
459
                record = [rec['name'], rec['put_timestamp'],
458
460
                          rec['delete_timestamp'], rec['object_count'],
466
468
                '''
467
469
                if self.get_db_version(conn) >= 1:
468
470
                    query += ' AND deleted IN (0, 1)'
469
 
                curs = conn.execute(query, (rec['name'],))
470
 
                curs.row_factory = None
471
 
                row = curs.fetchone()
 
471
                curs_row = curs.execute(query, (rec['name'],))
 
472
                curs_row.row_factory = None
 
473
                row = curs_row.fetchone()
472
474
                if row:
473
475
                    row = list(row)
474
476
                    for i in xrange(5):
484
486
                        record[5] = 1
485
487
                    else:
486
488
                        record[5] = 0
487
 
                conn.execute('''
 
489
                curs.execute('''
488
490
                    DELETE FROM container WHERE name = ? AND
489
491
                                                deleted IN (0, 1)
490
492
                ''', (record[0],))
491
 
                conn.execute('''
 
493
                curs.execute('''
492
494
                    INSERT INTO container (name, put_timestamp,
493
495
                        delete_timestamp, object_count, bytes_used,
494
496
                        deleted, storage_policy_index)
498
500
                    max_rowid = max(max_rowid, rec['ROWID'])
499
501
            if source:
500
502
                try:
501
 
                    conn.execute('''
 
503
                    curs.execute('''
502
504
                        INSERT INTO incoming_sync (sync_point, remote_id)
503
505
                        VALUES (?, ?)
504
506
                    ''', (max_rowid, source))
505
507
                except sqlite3.IntegrityError:
506
 
                    conn.execute('''
 
508
                    curs.execute('''
507
509
                        UPDATE incoming_sync
508
510
                        SET sync_point=max(?, sync_point)
509
511
                        WHERE remote_id=?