Terkunci Synchronize Files to Azure blob

  • 14 Desember 2009 3:44
     
     
    Hi,
    I have download the samples from http://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=sync&ReleaseId=3638 I was able to upload files from filesystem to Azure blob however the download says "creating file... but i dont see any files created in the targetted directory.  Initially it was error at FileRetreiver.cs as shown below

     

    public string AbsoluteSourceFilePath

    {

     

    get

    {

     

    throw new NotImplementedException("Absolute Path Not Supported");

    }

    }

    I change this code to return the path but file is not created.  Am i missing anything?

    It will be nice if you guys create New root level category like SyncFx-AzureSynchronization.

    Thanks.

    • Dipindahkan oleh Max Wang_Chinasoft 19 April 2011 22:48 Forum consolidation (From:SyncFx - Technical Discussion [ReadOnly])
    •  

Semua Balasan

  • 14 Desember 2009 4:30
     
     Jawab

    It works only if i set the value of RelativePath to Empty.  I also noticed that Delete method leads to concurrency violation hence i modified to
    blob.Delete(opts); --Leads to concurrency violation
    blob.DeleteIfExists();--Does the delete without error.

    Not sure why but it works.

    Thanks.

  • 19 Desember 2009 13:07
     
      Memiliki Kode

    "Delete method leads to concurrency violation"

    Do you mean in AzureBlobStore.cs @ line 373 (in DeleteFile)?

    // Specify an optimistic concurrency check to prevent races with other endpoints syncing at the same time.
    BlobRequestOptions opts = new BlobRequestOptions();
    opts.AccessCondition = AccessCondition.IfNotModifiedSince(expectedLastModified);
    
    try
    {
           blob.Delete(opts);
    }
    

    The problem is that the ListBlobs request is not bringing back the LastModified DateTime, so the AccessCondition is never met and you get a violation.

    So DeleteIfExists just works because it doesn't check the concurrency condition.

    To fix this (and probably other issues) add a call to FetchAttributes to the ListBlobs method in AzureBlobStore.cs:

    foreach (IListBlobItem o in Container.ListBlobs(opts))
    {
        CloudBlob blob = Container.GetBlobReference(o.Uri.ToString());
        blob.FetchAttributes(); // Add this line to ensure that attributes are enumerated
        ItemFieldDictionary dict = new ItemFieldDictionary();