Exemple #1
0
        /* Function: PickDeletedFile
         * Picks a deleted file to work on, if there are any.  If not it will return null.  Picked files will be added to <filesBeingProcessed>
         * and must be released with <FinalizeDeletedFile()>.
         */
        protected File PickDeletedFile()
        {
            lock (accessLock)
            {
                for (;;)
                {
                    int fileID = Manager.UnprocessedChanges.PickDeletedFileID();

                    if (fileID == 0)
                    {
                        return(null);
                    }

                    // If it's not being processed by another thread, return it.
                    if (!filesBeingProcessed.Contains(fileID))
                    {
                        File file = Manager.FromID(fileID);
                        filesBeingProcessed.Add(file);
                        return(file);
                    }

                    // If it is being processed by another thread, discard it and pick again.  It's okay to discard it from the list
                    // of changes because when processing ends FinalizeDeletedFile() will compare it to the snapshot in
                    // filesBeingProcessed and re-add it to the change list if it's different.
                }
            }
        }
Exemple #2
0
        override protected void Dispose(bool strictRulesApply)
        {
            if (!strictRulesApply)
            {
                // Set the last modification time to zero for anything still being worked on
                DateTime zero = new DateTime(0);

                foreach (int id in unprocessedChangedFileIDs)
                {
                    Manager.FromID(id).LastModified = zero;
                }
                foreach (int id in unprocessedDeletedFileIDs)
                {
                    Manager.FromID(id).LastModified = zero;
                }
                foreach (int id in claimedFileIDs)
                {
                    Manager.FromID(id).LastModified = zero;
                }
            }
        }
Exemple #3
0
        /* Function: ClaimDeletedFile
         * Claims a deleted file to work on, if there are any.  Will return null if not.  Claimed files must be released with
         * <ReleaseClaimedFile()>.
         */
        public File ClaimDeletedFile()
        {
            lock (accessLock)
            {
                if (unprocessedDeletedFileIDs.IsEmpty)
                {
                    return(null);
                }

                int fileID = unprocessedDeletedFileIDs.Highest;

                File file = Manager.FromID(fileID);
                file.Claimed            = true;
                file.StatusSinceClaimed = FileFlags.UnchangedSinceClaimed;

                unprocessedDeletedFileIDs.Remove(fileID);
                claimedFileIDs.Add(fileID);

                return(file);
            }
        }