~ubuntu-branches/ubuntu/oneiric/ubuntuone-client/oneiric

« back to all changes in this revision

Viewing changes to ubuntuone/syncdaemon/filesystem_manager.py

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Moya
  • Date: 2010-06-23 23:08:15 UTC
  • mto: This revision was merged to the branch mainline in revision 34.
  • Revision ID: james.westby@ubuntu.com-20100623230815-4m3ugh10u9x9xzw5
Tags: upstream-1.3.2
ImportĀ upstreamĀ versionĀ 1.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
from ubuntuone.syncdaemon.volume_manager import VolumeDoesNotExist
33
33
import uuid
34
34
 
35
 
METADATA_VERSION = "4"
 
35
METADATA_VERSION = "5"
36
36
 
37
37
#
38
38
# File System Manager  (FSM)
331
331
            if mdobj["server_hash"] is None:
332
332
                mdobj["server_hash"] = ""
333
333
 
 
334
            # add the generation number (new to v5)
 
335
            mdobj["generation"] = None
 
336
 
334
337
            # write back the object
335
338
            self.fs[mdid] = mdobj
336
339
 
359
362
 
360
363
            # fix the path
361
364
            self._fix_path_for_new_layout(mdobj)
 
365
 
 
366
            # add the generation number (new to v5)
 
367
            mdobj["generation"] = None
 
368
 
362
369
            # write back the object
363
370
            self.fs[mdid] = mdobj
364
371
 
385
392
 
386
393
            # fix the path
387
394
            self._fix_path_for_new_layout(mdobj)
 
395
 
 
396
            # add the generation number (new to v5)
 
397
            mdobj["generation"] = None
 
398
 
388
399
            # write back the object
389
400
            self.fs[mdid] = mdobj
390
401
 
405
416
        for mdid, mdobj in self._safe_fs_iteritems():
406
417
            # fix the path
407
418
            self._fix_path_for_new_layout(mdobj)
408
 
            # write back the object
409
 
            self.fs[mdid] = mdobj
 
419
 
 
420
            # add the generation number (new to v5)
 
421
            mdobj["generation"] = None
 
422
 
 
423
            # write back the object
 
424
            self.fs[mdid] = mdobj
 
425
 
 
426
            # and of course, load the metadata
 
427
            abspath = self.get_abspath(mdobj["share_id"], mdobj["path"])
 
428
            self._idx_path[abspath] = mdid
 
429
            if mdobj["node_id"] is not None:
 
430
                self._idx_node_id[(mdobj["share_id"], mdobj["node_id"])] = mdid
 
431
 
 
432
        # set new version
 
433
        with open(self._version_file, "w") as fh:
 
434
            fh.write(METADATA_VERSION)
 
435
 
 
436
    def _load_metadata_4(self, old_version):
 
437
        """Loads metadata from version 4."""
 
438
        logger("loading metadata from old version %r", old_version)
 
439
 
 
440
        for mdid, mdobj in self._safe_fs_iteritems():
 
441
            # add the generation number (new to v5)
 
442
            mdobj["generation"] = None
 
443
 
 
444
            # write back the object
 
445
            self.fs[mdid] = mdobj
 
446
 
410
447
            # and of course, load the metadata
411
448
            abspath = self.get_abspath(mdobj["share_id"], mdobj["path"])
412
449
            self._idx_path[abspath] = mdid
441
478
        relpath = self._share_relative_path(share_id, path)
442
479
        newobj = dict(path=relpath, node_id=None, share_id=share_id,
443
480
                      is_dir=is_dir, local_hash="", server_hash="",
444
 
                      mdid=mdid)
 
481
                      mdid=mdid, generation=None)
445
482
        newobj["info"] = dict(created=time.time(), is_partial=False)
446
483
        # only one stat, (instead of os.path.exists & os.stat)
447
484
        newobj["stat"] = get_stat(path)