Revision 3c76f045 trunk/Pithos.Core/Agents/NetworkAgent.cs

b/trunk/Pithos.Core/Agents/NetworkAgent.cs
45 45
using System.Linq;
46 46
using System.Net;
47 47
using System.Threading.Tasks;
48
using System.Threading.Tasks.Dataflow;
48 49
using Castle.ActiveRecord;
49 50
using Pithos.Interfaces;
50 51
using Pithos.Network;
......
59 60
        private Agent<CloudAction> _agent;
60 61

  
61 62
        //A separate agent is used to execute delete actions immediatelly;
62
        private Agent<CloudDeleteAction> _deleteAgent;
63
        private ActionBlock<CloudDeleteAction> _deleteAgent;
63 64
        readonly ConcurrentDictionary<string,DateTime> _deletedFiles=new ConcurrentDictionary<string, DateTime>();
64 65

  
65 66
        [System.ComponentModel.Composition.Import]
......
86 87
                loop();
87 88
            });
88 89

  
89
            _deleteAgent = Agent<CloudDeleteAction>.Start(inbox =>
90
            {
90
            _deleteAgent = new ActionBlock<CloudDeleteAction>(message =>ProcessDelete(message),new ExecutionDataflowBlockOptions{MaxDegreeOfParallelism=4});
91
            /*
91 92
                Action loop = null;
92 93
                loop = () =>
93 94
                            {
......
96 97
                                inbox.LoopAsync(process, loop);
97 98
                            };
98 99
                loop();
100
*/
99 101

  
100
            });
101 102
        }
102 103

  
103 104
        private async Task Process(CloudAction action)
......
128 129
                    if (IsDeletedFile(action))
129 130
                    {
130 131
                        //Clear the status of already deleted files to avoid reprocessing
131
                        this.StatusKeeper.ClearFileStatus(action.LocalFile.FullName);
132
                        if (action.LocalFile != null)
133
                            this.StatusKeeper.ClearFileStatus(action.LocalFile.FullName);
132 134
                    }
133 135
                    else
134 136
                    {
......
231 233
                        var key = GetFileKey(action.CloudFile);
232 234
                        _deletedFiles[key]=DateTime.Now;
233 235

  
236

  
234 237
                        // and then delete the file from the server
235 238
                        DeleteCloudFile(accountInfo, cloudFile);
239

  
236 240
                        Log.InfoFormat("[ACTION] End Delete {0}:{1}->{2}", action.Action, action.LocalFile,
237 241
                                       action.CloudFile.Name);
238 242
                    }
......
949 953
                        //If the directory doesn't exist the Hash property will be empty
950 954
                        if (String.IsNullOrWhiteSpace(info.Hash))
951 955
                            //Go on and create the directory
952
                            client.PutObject(account, cloudFile.Container, cloudFile.Name, fullFileName, String.Empty, "application/directory");
956
                            await client.PutObject(account, cloudFile.Container, cloudFile.Name, fullFileName, String.Empty, "application/directory");
953 957
                    }
954 958
                    else
955 959
                    {

Also available in: Unified diff