removed dead code
added FileHashCode to print item Made hash code for print item wrapper 64 bit (long).
This commit is contained in:
parent
219b14aaf4
commit
901835aedc
4 changed files with 32 additions and 19 deletions
|
|
@ -189,6 +189,8 @@ namespace MatterHackers.MatterControl.DataStorage
|
|||
|
||||
public string FileLocation { get; set; }
|
||||
|
||||
public long FileHashCode { get; set; }
|
||||
|
||||
public DateTime DateAdded { get; set; }
|
||||
|
||||
public int PrintCount { get; set; }
|
||||
|
|
|
|||
|
|
@ -534,7 +534,7 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
}
|
||||
|
||||
if (firstDraw && commandLineArgs.Length < 2)
|
||||
if (firstDraw)
|
||||
{
|
||||
UiThread.RunOnIdle(DoAutoConnectIfRequired);
|
||||
|
||||
|
|
@ -550,16 +550,6 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
|
||||
TerminalWindow.ShowIfLeftOpen();
|
||||
|
||||
#if false
|
||||
foreach (CreatorInformation creatorInfo in RegisteredCreators.Instance.Creators)
|
||||
{
|
||||
if (creatorInfo.description.Contains("Image"))
|
||||
{
|
||||
creatorInfo.functionToLaunchCreator(null, null);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//msGraph.AddData("ms", totalDrawTime.ElapsedMilliseconds);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace MatterHackers.MatterControl.PrintQueue
|
|||
|
||||
private String fileType;
|
||||
|
||||
private int fileHashCode;
|
||||
private long fileHashCode;
|
||||
private long writeTime = 0;
|
||||
|
||||
public bool CurrentlySlicing { get; set; }
|
||||
|
|
@ -152,14 +152,15 @@ namespace MatterHackers.MatterControl.PrintQueue
|
|||
set { this.PrintItem.FileLocation = value; }
|
||||
}
|
||||
|
||||
public int FileHashCode
|
||||
public long FileHashCode
|
||||
{
|
||||
get
|
||||
{
|
||||
long currentWriteTime = File.GetLastWriteTime(this.FileLocation).ToBinary();
|
||||
bool fileExists = System.IO.File.Exists(this.FileLocation);
|
||||
if (fileExists)
|
||||
{
|
||||
long currentWriteTime = File.GetLastWriteTime(this.FileLocation).ToBinary();
|
||||
|
||||
if (this.fileHashCode == 0 || writeTime != currentWriteTime)
|
||||
{
|
||||
writeTime = currentWriteTime;
|
||||
|
|
@ -167,7 +168,7 @@ namespace MatterHackers.MatterControl.PrintQueue
|
|||
{
|
||||
long sizeOfFile = fileStream.Length;
|
||||
int sizeOfRead = 1 << 16;
|
||||
byte[] readData = new byte[sizeOfRead * 3];
|
||||
byte[] readData = new byte[Math.Max(64, sizeOfRead * 3)];
|
||||
|
||||
// get a chuck from the begining
|
||||
fileStream.Read(readData, sizeOfRead, sizeOfRead);
|
||||
|
|
@ -187,12 +188,29 @@ namespace MatterHackers.MatterControl.PrintQueue
|
|||
readData[i] = fileSizeAsBytes[i];
|
||||
}
|
||||
|
||||
int hashCode = agg_basics.ComputeHash(readData);
|
||||
int fileSizeInt = (int)sizeOfFile;
|
||||
this.fileHashCode = new { hashCode, currentWriteTime, fileSizeInt }.GetHashCode();
|
||||
// push the file size into the first bytes
|
||||
byte[] writeTimeAsBytes = BitConverter.GetBytes(currentWriteTime);
|
||||
for (int i = 0; i < writeTimeAsBytes.Length; i++)
|
||||
{
|
||||
readData[fileSizeAsBytes.Length + i] = fileSizeAsBytes[i];
|
||||
}
|
||||
|
||||
this.fileHashCode = agg_basics.ComputeHash(readData);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.fileHashCode = 0;
|
||||
}
|
||||
|
||||
if (PrintItem != null
|
||||
&& PrintItem.FileHashCode != this.fileHashCode)
|
||||
{
|
||||
PrintItem.FileHashCode = this.fileHashCode;
|
||||
PrintItem.Commit();
|
||||
}
|
||||
|
||||
|
||||
return this.fileHashCode;
|
||||
}
|
||||
|
|
@ -260,6 +278,9 @@ namespace MatterHackers.MatterControl.PrintQueue
|
|||
|
||||
public void OnFileHasChanged()
|
||||
{
|
||||
// Get the hashcode so we can save it if it has changed.
|
||||
long fileHashCode = FileHashCode;
|
||||
|
||||
if (FileHasChanged != null)
|
||||
{
|
||||
FileHasChanged.CallEvents(this, null);
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit c6b7b43313bb2f899277066c8a89c48b70ecf42b
|
||||
Subproject commit 9774d0611c17b73bf7fb3dd088d6890fa9a9a4e6
|
||||
Loading…
Add table
Add a link
Reference in a new issue