Esempio n. 1
0
        private void RepairDuplicates()
        {
            var collectionPath = _model.TheOneEditableCollection.PathToDirectory;

            // A book's ID may not be changed if we have a TC and the book is actually in the shared folder.
            // Eventually we may allow it if the book is checked out.
            BookInfo.RepairDuplicateInstanceIds(collectionPath, (bookPath) =>
            {
                if (_tcManager?.CurrentCollection == null)
                {
                    return(true);                    // OK to change, not a TC.
                }
                // Only OK if not present in the TC repo.
                return(!_tcManager.CurrentCollection.IsBookPresentInRepo(Path.GetFileName(bookPath)));
            });
        }
Esempio n. 2
0
 /// <summary>
 /// In the past we've had problems with users copying folders manually and creating derivative books with
 /// the same bookInstanceId guids. Then we try to bulk upload a folder structure with books like this and the
 /// duplicates overwrite whichever book got uploaded first.
 /// This method recurses through the folders under 'rootFolderPath' and keeps track of all the unique bookInstanceId
 /// guids. When a duplicate is found, we will call BookInfo.InstallFreshInstanceGuid().
 /// </summary>
 /// <remarks>Internal for testing.</remarks>
 /// <param name="rootFolderPath"></param>
 internal static void BulkRepairInstanceIds(string rootFolderPath)
 {
     BookInfo.RepairDuplicateInstanceIds(rootFolderPath);
 }
Esempio n. 3
0
 /// <summary>
 /// In the past we've had problems with users copying folders manually and creating derivative books with
 /// the same bookInstanceId guids. Then we try to bulk upload a folder structure with books like this and the
 /// duplicates overwrite whichever book got uploaded first.
 /// This method recurses through the folders under 'rootFolderPath' and keeps track of all the unique bookInstanceId
 /// guids. When a duplicate is found, we will call BookInfo.InstallFreshInstanceGuid().
 /// </summary>
 /// <remarks>Internal for testing.</remarks>
 /// <param name="rootFolderPath"></param>
 /// <param name="okToChangeId">If this function returns true for a folder path, that book's ID may be changed.</param>
 internal static void BulkRepairInstanceIds(string rootFolderPath, Func <string, bool> okToChangeId)
 {
     BookInfo.RepairDuplicateInstanceIds(rootFolderPath, okToChangeId);
 }