123123
This commit is contained in:
@@ -179,8 +179,6 @@ namespace ZelWiki.Repository
|
||||
var pageFileInfo = GetPageFileInfoByFileNavigation(o, item.PageId, item.FileNavigation);
|
||||
if (pageFileInfo == null)
|
||||
{
|
||||
//If the page file does not exist, then insert it.
|
||||
|
||||
var InsertPageFileParam = new
|
||||
{
|
||||
PageId = item.PageId,
|
||||
@@ -193,8 +191,7 @@ namespace ZelWiki.Repository
|
||||
};
|
||||
|
||||
o.Execute("InsertPageFile.sql", InsertPageFileParam);
|
||||
|
||||
//Get the id of the newly inserted page file.
|
||||
|
||||
pageFileInfo = GetPageFileInfoByFileNavigation(o, item.PageId, item.FileNavigation)
|
||||
?? throw new Exception("Failed find newly inserted page attachment.");
|
||||
|
||||
@@ -208,26 +205,19 @@ namespace ZelWiki.Repository
|
||||
var currentlyAttachedFile = GetPageCurrentRevisionAttachmentByFileNavigation(o, item.PageId, item.FileNavigation);
|
||||
if (currentlyAttachedFile != null)
|
||||
{
|
||||
//The PageFile exists and a revision of it is attached to this page revision.
|
||||
//Keep track of the file revision, and determine if the file has changed (via the file hash).
|
||||
|
||||
currentFileRevision = currentlyAttachedFile.Revision;
|
||||
hasFileChanged = currentlyAttachedFile.DataHash != newDataHash;
|
||||
}
|
||||
else
|
||||
{
|
||||
//The file either does not exist or is not attached to the current page revision.
|
||||
hasFileChanged = true;
|
||||
|
||||
//We determined earlier that the PageFile does exist, so keep track of the file revision.
|
||||
currentFileRevision = pageFileInfo.Revision;
|
||||
}
|
||||
|
||||
if (hasFileChanged)
|
||||
{
|
||||
currentFileRevision++;
|
||||
|
||||
//Get the current page revision so that we can associate the page file attachment with the current page revision.
|
||||
|
||||
int currentPageRevision = PageRepository.GetCurrentPageRevision(o, item.PageId);
|
||||
|
||||
var updatePageFileRevisionParam = new
|
||||
@@ -235,7 +225,6 @@ namespace ZelWiki.Repository
|
||||
PageFileId = pageFileInfo.PageFileId,
|
||||
FileRevision = currentFileRevision
|
||||
};
|
||||
//The file has changed (or is newly inserted), bump the file revision.
|
||||
o.Execute("UpdatePageFileRevision.sql", updatePageFileRevisionParam);
|
||||
|
||||
var insertPageFileRevisionParam = new
|
||||
@@ -250,7 +239,6 @@ namespace ZelWiki.Repository
|
||||
DataHash = newDataHash,
|
||||
};
|
||||
|
||||
//Insert the actual file data.
|
||||
o.Execute("InsertPageFileRevision.sql", insertPageFileRevisionParam);
|
||||
|
||||
var associatePageFileAttachmentWithPageRevisionParam = new
|
||||
@@ -259,10 +247,9 @@ namespace ZelWiki.Repository
|
||||
PageFileId = pageFileInfo.PageFileId,
|
||||
PageRevision = currentPageRevision,
|
||||
FileRevision = currentFileRevision,
|
||||
PreviousFileRevision = currentlyAttachedFile?.Revision //This is so we can disassociate the previous file revision.
|
||||
PreviousFileRevision = currentlyAttachedFile?.Revision
|
||||
};
|
||||
|
||||
//Associate the latest version of the file with the latest version of the page.
|
||||
o.Execute("AssociatePageFileAttachmentWithPageRevision.sql", associatePageFileAttachmentWithPageRevisionParam);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user