Revision 4147814e

b/trunk/Pithos.Client.WPF/SelectiveSynch/SelectiveSynchViewModel.cs
42 42
using System;
43 43
using System.Collections.Generic;
44 44
using System.Collections.ObjectModel;
45
using System.Collections.Specialized;
46
using System.IO;
47 45
using System.Linq;
48
using System.Text;
49 46
using System.Threading.Tasks;
50 47
using Caliburn.Micro;
51 48
using Pithos.Client.WPF.Properties;
52 49
using Pithos.Core;
53
using Pithos.Core.Agents;
54 50
using Pithos.Interfaces;
55
using Pithos.Network;
56 51

  
57 52
namespace Pithos.Client.WPF.SelectiveSynch
58 53
{
59 54
    class SelectiveSynchViewModel:Screen
60 55
    {
61 56
        private const string DirectoryType = "application/directory";
62
        private IEventAggregator _events ;
57
        private readonly IEventAggregator _events ;
63 58

  
64 59
        private string _title;
65 60
        public string Title
......
81 76
        }
82 77

  
83 78
        private ObservableCollection<ObjectInfo> _checks;
84
        private PithosMonitor _monitor;
79
        private readonly PithosMonitor _monitor;
85 80
        private bool _isBusy=true;
86 81

  
87 82
        public ObservableCollection<ObjectInfo> Checks
......
124 119
                                  };
125 120
            var ownFolders = dirs.ToList();
126 121

  
127
            var accounts = client.ListSharingAccounts();
128

  
129 122
            var accountNodes=from account in client.ListSharingAccounts()
130 123
                             select new DirectoryRecord
131 124
                             {
......
155 148

  
156 149
            Execute.OnUIThread(() =>
157 150
                                   {
158
                                       this.RootNodes.Add(rootItem);
159
                                       this.RootNodes.Add(othersNode);
151
                                       RootNodes.Add(rootItem);
152
                                       RootNodes.Add(othersNode);
160 153
                                   });
161 154

  
162 155
            SetInitialSelections(Account);
b/trunk/Pithos.Core/FileState.cs
420 420
        }
421 421

  
422 422
        /// <summary>
423
        /// Remove all FileState rows from the database whose path
423
        /// Mark Unversioned all FileState rows from the database whose path
424 424
        /// starts with one of the removed paths
425 425
        /// </summary>
426 426
        /// <param name="removed"></param>
427
        public static void RemovePaths(List<string> removed)
427
        public static void UnversionPaths(List<string> removed)
428 428
        {
429 429
            if (removed == null)
430 430
                return;
......
442 442

  
443 443
            //Generate a query from the disjunction
444 444
            var query=QueryOver.Of<FileState>().Where(disjunction);
445
            //Adn retrieveonly the IDs
446
            var idQuery = new ProjectionQuery<FileState,Guid>(query.DetachedCriteria,
447
                Projections.ProjectionList()
448
                .Add(Projections.Id()));
449
            
450
            var ids=idQuery.Execute();
451
            DeleteAll(ids);
452
                
445
                        
446
            ExecuteWithRetry((session,instance)=>
447
                                 {
448
                                     using (var t=session.BeginTransaction())
449
                                     {
450
                                         var states = query.GetExecutableQueryOver(session).List();
451
                                         foreach (var state in states)
452
                                         {
453
                                             state.FileStatus = FileStatus.Unversioned;
454
                                             state.OverlayStatus = FileOverlayStatus.Unversioned;
455
                                             state.Update();
456
                                         }
457
                                         t.Commit();
458
                                     }
459
                                     return null;
460
                                 },null);
453 461
        }
462

  
454 463
    }
455 464

  
456 465
    [ActiveRecord("Tags")]
b/trunk/Pithos.Core/IPithosWorkflow.cs
62 62
        Modified,
63 63
        Renamed,
64 64
        Deleted,
65
        Conflict
65
        Conflict,
66
        Unversioned
66 67
    }
67 68
}
b/trunk/Pithos.Core/PithosMonitor.cs
483 483
            
484 484
            FileAgent.SelectivePaths=selectivePaths;
485 485
            PollAgent.SetSyncUris(uris);
486

  
486
            
487 487
            var removedPaths = UrisToFilePaths(removed);
488
            RemoveSelectivePaths(removedPaths);
488
            UnversionSelectivePaths(removedPaths);
489

  
490
        }
491

  
492
        /// <summary>
493
        /// Mark all unselected paths as Unversioned
494
        /// </summary>
495
        /// <param name="removed"></param>
496
        private void UnversionSelectivePaths(List<string> removed)
497
        {
498
            if (removed == null)
499
                return;
489 500

  
501
            //Ensure we remove any file state below the deleted folders
502
            FileState.UnversionPaths(removed);
490 503
        }
491 504

  
505

  
492 506
        /// <summary>
493 507
        /// Return a list of absolute filepaths from a list of Uris
494 508
        /// </summary>
......
507 521
                    select Path.Combine(RootPath, relativePath.After(_accountInfo.UserName + '\\'))).ToList();            
508 522
        }
509 523

  
510
        /// <summary>
511
        /// Delete the folders that were removed from synchronization
512
        /// </summary>
513
        /// <param name="removed"></param>
514
        private void RemoveSelectivePaths(List<string> removed)
515
        {
516
            if (removed == null)
517
                return;
518

  
519
            foreach (var removedPath in removed.Where(Directory.Exists))
520
            {
521
                try
522
                {
523
                    Directory.Delete(removedPath, true);
524
                }
525
                catch { }
526
            }
527

  
528
            //Ensure we remove any file state below the deleted folders
529
            FileState.RemovePaths(removed);
530
        }
531 524

  
532 525
        public ObjectInfo GetObjectInfo(string filePath)
533 526
        {

Also available in: Unified diff