diff --git a/server/AyaNova/Controllers/AttachmentController.cs b/server/AyaNova/Controllers/AttachmentController.cs
index 964e1ddd..c6757f16 100644
--- a/server/AyaNova/Controllers/AttachmentController.cs
+++ b/server/AyaNova/Controllers/AttachmentController.cs
@@ -498,71 +498,35 @@ namespace AyaNova.Api.Controllers
return v;
}
+
+
+ ///
+ /// Trigger immediate AttachmentMaintenanceJob
+ ///
+ ///
+ /// Job Id
+ [HttpPost("maintenance")]
+ [Authorize]
+ public async Task PostTriggerAttachmentMaintenanceJob()
+ {
+ if (serverState.IsClosed)
+ return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
+ if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.FileAttachment))
+ return StatusCode(403, new ApiNotAuthorizedResponse());
+ var JobName = $"Attachment maintenance (demand)";
+ OpsJob j = new OpsJob();
+ j.Name = JobName;
+ j.ObjectType = AyaType.FileAttachment;
+ j.JobType = JobType.AttachmentMaintenance;
+ j.SubType = JobSubType.NotSet;
+ j.Exclusive = true;
+ await JobsBiz.AddJobAsync(j);
+ await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.ServerJob, AyaEvent.Created, JobName), ct);
+ return Accepted(new { JobId = j.GId });
+ }
+
+
}//eoc
}//eons
-#region sample html form to work with this
-/*
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- */
-#endregion
\ No newline at end of file
diff --git a/server/AyaNova/biz/AttachmentBiz.cs b/server/AyaNova/biz/AttachmentBiz.cs
index cd618863..76a8c123 100644
--- a/server/AyaNova/biz/AttachmentBiz.cs
+++ b/server/AyaNova/biz/AttachmentBiz.cs
@@ -64,6 +64,9 @@ namespace AyaNova.Biz
await JobsBiz.LogJobAsync(job.GId, $"Starting...");
apiServerState.SetOpsOnly("Attachment file maintenance");
+
+
+
// EXISTENCE CHECK
//iterate all records in chunks
bool moreRecords = true;
@@ -93,9 +96,9 @@ namespace AyaNova.Biz
}
} while (moreRecords);
- // long totalRecs = await ct.FileAttachment.LongCountAsync();
-
+ // long totalRecs = await ct.FileAttachment.LongCountAsync();
+ var allAttachments = FileUtil.GetAllAttachmentFilePaths();
// iterate FileAttachment records, if physically present then flag as such
// make sure it has a short circuit that if there are NO files physically then all are out of sync
diff --git a/server/AyaNova/util/FileUtil.cs b/server/AyaNova/util/FileUtil.cs
index 6d56e69c..9748f953 100644
--- a/server/AyaNova/util/FileUtil.cs
+++ b/server/AyaNova/util/FileUtil.cs
@@ -512,8 +512,7 @@ namespace AyaNova.Util
///
/// Confirm if a file exists in the attachment folder
///
- /// name of attachment file
- /// duh!
+ /// name of attachment file
internal static bool AttachmentFileExists(string fileName)
{
if (string.IsNullOrWhiteSpace(fileName))