- var d0 = FileState.Queryable
- .Where(state =>
- state.FilePath.StartsWith(accountInfo.AccountPath)).ToList();
-
- var d1 = FileState.Queryable
- .Where(state => state.Modified <= pollTime).ToList();
- var d2= FileState.Queryable
- .Where(state => state.Modified <= pollTime
- &&
- state.FilePath.StartsWith(accountInfo.AccountPath)).ToList();*/
-
- //Consider for deleteion only files modified before the PREVIOUS poll
- //A user may perform a file creation or rename at roughly the same time as a poll. In such a case
- //the new file will appear as deleted
- var previousPollTime = pollTime.Subtract(TimeSpan.FromMilliseconds(Settings.PollingInterval));
-
- //Only consider files that are not being modified, ie they are in the Unchanged state
- var deleteCandidates = FileState.Queryable.Where(state =>
- state.Modified <= previousPollTime
- && state.FilePath.StartsWith(accountInfo.AccountPath)
- && state.FileStatus == FileStatus.Unchanged).ToList();
-
- //TODO: filesToDelete must take into account the Others container
- var filesToDelete = (from deleteCandidate in deleteCandidates
- let localFile = FileInfoExtensions.FromPath(deleteCandidate.FilePath)
- let relativeFilePath = localFile.AsRelativeTo(accountInfo.AccountPath)
- let agentActions = _agent.GetEnumerable()
- where
- !_lastSeen.ContainsKey(localFile.FullName)
- && !cloudFiles.Any(r => r.RelativeUrlToFilePath(accountInfo.UserName) == relativeFilePath )
- //Exclude files enqueued for uploading
- //Large files will not appear on the server for multiple polls. They must not be marked as deleted
- && !agentActions.Any(action => action.LocalFile.WithProperCapitalization().FullName == localFile.FullName)
- //Do NOT delete files modified since the previous poll
- && localFile.LastAccessTime < previousPollTime
- select localFile).ToList();
-