Login | ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/indexer_suite/trunk/IndexCreatorForm.pas
(Generate patch)

Comparing trunk/IndexCreatorForm.pas (file contents):
Revision 5 by daniel-marschall, Mon Dec 10 00:06:35 2018 UTC vs.
Revision 6 by daniel-marschall, Tue Dec 11 23:24:20 2018 UTC

# Line 160 | Line 160 | begin
160    Result := SystemTimeToDateTime(systime);
161   end;
162  
163 function UTCTimeToLocalTime(const aValue: TDateTime): TDateTime;
164 var
165  lBias: Integer;
166  lTZI: TTimeZoneInformation;
167 begin
168  lBias := 0;
169  case GetTimeZoneInformation(lTZI) of
170    TIME_ZONE_ID_UNKNOWN:
171      lBias := lTZI.Bias;
172    TIME_ZONE_ID_DAYLIGHT:
173      lBias := lTZI.Bias + lTZI.DaylightBias;
174    TIME_ZONE_ID_STANDARD:
175      lBias := lTZI.Bias + lTZI.StandardBias;
176  end;
177  // UTC = local time + bias
178  // bias is in number of minutes, TDateTime is in days
179  Result := aValue - (lBias / (24 * 60));
180 end;
181
163   function GetFileSize(const AFileName: String): int64;
164   var
165    lFindData: TWin32FindData;
# Line 266 | Line 247 | begin
247   {$ENDIF}
248   end;
249  
250 + function SpecialCompare(a, b: TDateTime): boolean; // true = same timestamp
251 + begin
252 +  if SecondsBetween(a,b) < 2 then exit(true); // equal
253 +
254 +  if SecondsBetween(a,b) > 7200 then exit(false);
255 +
256 +  // Minute and Second equal, and difference is < 2h: fair enough, seems to be a DST issue
257 +  if copy(TimeToStr(a),4,5) = copy(TimeToStr(b),4,5) then exit(true);
258 +
259 +  result := false;
260 + end;
261 +
262   procedure TfrmIndexCreator.CheckFile(const originalFileName,
263    uniqueFilename: string);
264  
# Line 296 | Line 289 | var
289          Result := erDoesNotExist
290        else if not q.Fields[0].IsNull then
291          Result := erHadError
292 <      else if (q.Fields[1].AsString <> IntToStr(size)) or
293 <      // we are combining strings because of int64
301 <        (SecondsBetween(q.Fields[2].AsDateTime, UTCTimeToLocalTime(modified)
302 <        ) > 2) then
292 >      else if (q.Fields[1].AsString <> IntToStr(size)) or // we are combining strings because of int64
293 >        not SpecialCompare(q.Fields[2].AsDateTime, modified) then
294        begin
295          Result := erChanged
296        end
# Line 342 | Line 333 | begin
333          conn.ExecSQL('INSERT INTO ' + TableName +
334            ' (filename, size, created, modified, md5hash, error) values (' +
335            conn.SQLStringEscape(VtsSpecial(uniqueFilename)) + ', ' +
336 <          IntToStr(size) + ', ' + DateTimeToSQL(UTCTimeToLocalTime(created)) +
337 <          ', ' + DateTimeToSQL(UTCTimeToLocalTime(modified)) + ', ' +
336 >          IntToStr(size) + ', ' + DateTimeToSQL(created) +
337 >          ', ' + DateTimeToSQL(modified) + ', ' +
338            conn.SQLStringEscape(LowerCase(md5)) + ', NULL);');
339        end;
340        if cbVerboseLogs.Checked then
# Line 364 | Line 355 | begin
355                  ' (filename, size, created, modified, md5hash, error) values ('
356                  + conn.SQLStringEscape(VtsSpecial(uniqueFilename)) + ', ' +
357                  IntToStr(size) + ', ' +
358 <                DateTimeToSQL(UTCTimeToLocalTime(created)) + ', ' +
359 <                DateTimeToSQL(UTCTimeToLocalTime(modified)) + ', ' +
358 >                DateTimeToSQL(created) + ', ' +
359 >                DateTimeToSQL(modified) + ', ' +
360                  conn.SQLStringEscape(LowerCase(md5)) + ', NULL);');
361              end;
362              if cbVerboseLogs.Checked then
# Line 381 | Line 372 | begin
372              begin
373                conn.ExecSQL('UPDATE ' + TableName + ' SET size = ' +
374                  IntToStr(size) + ', created = ' +
375 <                DateTimeToSQL(UTCTimeToLocalTime(created)) + ', modified = ' +
376 <                DateTimeToSQL(UTCTimeToLocalTime(modified)) + ', md5hash = ' +
375 >                DateTimeToSQL(created) + ', modified = ' +
376 >                DateTimeToSQL(modified) + ', md5hash = ' +
377                  conn.SQLStringEscape(LowerCase(md5)) +
378                  ', error = NULL WHERE filename = ' + conn.SQLStringEscape
379                  (VtsSpecial(uniqueFilename)) + ';');
# Line 393 | Line 384 | begin
384            end;
385          erUnchanged: // Date/Time+Size has not changed
386            begin
387 +            {$REGION 'Update it to correct wrong UTC/DST datasets...'}
388 +            conn.ExecSQL('UPDATE ' + TableName + ' SET size = ' +
389 +              IntToStr(size) + ', created = ' +
390 +              DateTimeToSQL(created) + ', modified = ' +
391 +              DateTimeToSQL(modified) +
392 +              ', error = NULL WHERE filename = ' + conn.SQLStringEscape
393 +              (VtsSpecial(uniqueFilename)) + ';');
394 +            {$ENDREGION}
395 +
396              if rgModus.ItemIndex = modusValidation then
397              begin
398                md5 := MD5File(uniqueFilename);
# Line 754 | Line 754 | begin
754        end;
755      *)
756    finally
757 <    EnableDisableControls(true);
757 >    if not StopRequest then EnableDisableControls(true);
758    end;
759  
760 <  Beep;
761 <  Label1.Caption := 'Done.';
762 <  Application.ProcessMessages;
760 >  if not StopRequest then
761 >  begin
762 >    Beep;
763 >    Label1.Caption := 'Done.';
764 >    Application.ProcessMessages;
765 >  end;
766   end;
767  
768   procedure TfrmIndexCreator.FormClose(Sender: TObject; var Action: TCloseAction);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines