diff --git a/CSRender/CSRender.cs b/CSRender/CSRender.cs index ec648143a5c6cf5aa15190d607b970d766f8949a..9d21ecc09bca0ac03e2896a6101b162ce375db06 100644 --- a/CSRender/CSRender.cs +++ b/CSRender/CSRender.cs @@ -619,6 +619,8 @@ namespace CSRender { public HashHead Head = new HashHead(); [DataMember(Order=1)] public SortedDictionary Files = new SortedDictionary(); + // temp value + string loadedPath; // メソッド static public string GetHashFileName(string baseName, string dpi, string box, string imType, string jq) { var h = new HashHead(); @@ -651,6 +653,7 @@ namespace CSRender { using (var rd = new FileStream(hashPath, FileMode.Open,FileAccess.Read,FileShare.ReadWrite)) { var a = (HashData)serializer.ReadObject(rd); a.Head.Dirty = false;// clear + a.loadedPath=hashPath; return a; } } @@ -756,6 +759,22 @@ namespace CSRender { var v = Files[fName].PageHashCode; return (n < v.Count) ? v[n] : ""; } + public bool IsValidHashFile(string[] fLst){ + // ハッシュファイルとPDFファイルの整合性確認。更新日付のみ確認。正常:true、異常:false + // + if (fLst.Count() != Files.Count ) + return false; // pdfファイル数の不一致 + + foreach (var f in Files) { + var fPath=Path.Combine( Path.GetDirectoryName(loadedPath) ,f.Key); + var fi = new FileInfo(fPath); + // Console.WriteLine(fPath+": "+f.Value.UpdateTimeStr); + // Console.WriteLine(fPath+"->"+fi.LastWriteTime.ToString()); + if ( f.Value.UpdateTimeStr != fi.LastWriteTime.ToString() ) + return false; // 1つでも異なっていたらすべてのファイルを異常とする + } + return true;//正常 + } } } diff --git a/CSRender/Program.cs b/CSRender/Program.cs index ec7d4f8a5f53551f4789e56df40595c7e25c9d52..afe11dc5f370c2f7bf22ed59e81d33fabd686c85 100644 --- a/CSRender/Program.cs +++ b/CSRender/Program.cs @@ -143,6 +143,7 @@ For more information,see /H /? or /? [ELSE ] その他のオプション /Para <プロセス並行数>:本Exeの並行数を指定(デフォルト4) /ParaPage <ページ処理スレッド数>:ページ処理のスレッド数を指定(デフォルト4) + /Verbose : 詳細表示 [obs]/NoExeSepa :実行分離しない(遅い) /H or /? : This help"); @@ -614,10 +615,19 @@ For more information,see /H /? or /? } else if (pm.bExeSepa &&(pm.bFC)) { // セパのFCモード /* refのハッシュが存在しなければWCFで作成 - tgtのハッシュは強制的にWCFで作成 + tgtのハッシュは強制的にWCFで作成->refと同様に存在しなければ作成 */ echo($"****************セパのFCモード******{argsStr}************"); + + // リファレンス側のハッシュチェック hashDataRef = HashData.load(pm.pdfPathRef, hashBaseName, pm.dpi, pm.boxSelect, pm.imageType, pm.jpegQ, ref otHashPath2); + // ハッシュファイルとファイルとの日付を比較する + Console.WriteLine(otHashPath2); + if ( (hashDataRef != null) && !hashDataRef.IsValidHashFile(pdfPathLst2)) { + // ハッシュファイルが異常→ファイルを削除 + File.Delete(otHashPath2); + hashDataRef=null; + } if ( hashDataRef == null ) { var myExePath = Assembly.GetExecutingAssembly().Location; var proc = Ut.Ut.DoCmd( @@ -633,7 +643,15 @@ For more information,see /H /? or /? } else { echo($" OK hash ref(already exist)"); } - if (true){ + // ターゲット側のハッシュチェック + hashDataTgt = HashData.load(pm.pdfPath, hashBaseName, pm.dpi, pm.boxSelect, pm.imageType, pm.jpegQ, ref otHashPath); + if ( (hashDataTgt != null) && !hashDataTgt.IsValidHashFile(pdfPathLst)) { + // ハッシュファイルが異常→ファイルを削除 + File.Delete(otHashPath); + hashDataTgt=null; + } + if ( hashDataTgt == null ) { + // ターゲット側のハッシュ計算 var myExePath = Assembly.GetExecutingAssembly().Location; var proc = Ut.Ut.DoCmd( cmdAndArgs: new string[] { myExePath, "/MkHash",pm.pdfPath,"/D",pm.dpi, $"/{pm.imageType }",$"/JPEGQ",pm.jpegQ } @@ -646,6 +664,20 @@ For more information,see /H /? or /? echo($" OK hash tgt"); } } + //if (false/*true*/){// 2022.5.7 なぜ常に作成していたか? K.Matsuo + // // ターゲット側のハッシュ計算 + // var myExePath = Assembly.GetExecutingAssembly().Location; + // var proc = Ut.Ut.DoCmd( + // cmdAndArgs: new string[] { myExePath, "/MkHash",pm.pdfPath,"/D",pm.dpi, $"/{pm.imageType }",$"/JPEGQ",pm.jpegQ } + // , bEcho: true + // , bSameConsole: true + // ); + // proc.WaitForExit(); + // hashDataTgt = HashData.load(pm.pdfPath, hashBaseName, pm.dpi, pm.boxSelect, pm.imageType, pm.jpegQ, ref otHashPath); + // if ( hashDataTgt != null ) { + // echo($" OK hash tgt"); + // } + //} echo($@"****************FC開始*****{argsStr}**************"); if (pm.resultPath != "") {// 初期化 File.WriteAllText(Path.GetFullPath(pm.resultPath), "");