Permalink
Browse files

save the creation and modification time of files

  • Loading branch information...
1 parent 07e7a03 commit 422877faab72d000c27095fb6d8227a73750eab4 @hbons committed Dec 21, 2012
Showing with 19 additions and 1 deletion.
  1. +8 −1 git-bin/Commands/SmudgeCommand.cs
  2. +11 −0 git-bin/GitBinDocument.cs
View
9 git-bin/Commands/SmudgeCommand.cs
@@ -30,8 +30,15 @@ public void Execute()
GitBinConsole.Write("Smudging {0}...", document.Filename);
DownloadMissingFiles(document.ChunkHashes);
-
OutputReassembledChunks(document.ChunkHashes);
+/* TODO: move to SparkleShare
+ string filepath = Path.Combine (Environment.CurrentDirectory,
+ document.Filename.Replace("/", Path.DirectorySeparatorChar.ToString()));
+
+ FileInfo fileInfo = new FileInfo(filepath);
+ fileInfo.CreationTimeUtc = new DateTime(1970, 1, 1).AddSeconds(document.CreationTime);
+ fileInfo.LastWriteTimeUtc = new DateTime(1970, 1, 1).AddSeconds(document.LastWriteTime);
+*/
}
private void DownloadMissingFiles(IEnumerable<string> chunkHashes)
View
11 git-bin/GitBinDocument.cs
@@ -9,6 +9,8 @@ namespace GitBin
public class GitBinDocument
{
public string Filename { get; private set; }
+ public int CreationTime { get; private set; }
+ public int LastWriteTime { get; private set; }
public List<string> ChunkHashes { get; private set; }
public GitBinDocument()
@@ -19,6 +21,15 @@ public GitBinDocument()
public GitBinDocument(string filename): this()
{
this.Filename = filename;
+
+ string filepath = Path.Combine(Environment.CurrentDirectory,
+ this.Filename.Replace("/", Path.DirectorySeparatorChar.ToString()));
+
+ DateTime creationTimeUtc = new FileInfo(filepath).CreationTimeUtc;
+ this.CreationTime = (int) (creationTimeUtc - new DateTime(1970, 1, 1)).TotalSeconds;
+
+ DateTime lastWriteTimeUtc = new FileInfo(filepath).LastWriteTimeUtc;
+ this.LastWriteTime = (int) (lastWriteTimeUtc - new DateTime(1970, 1, 1)).TotalSeconds;
}
public void RecordChunk(string hash)

0 comments on commit 422877f

Please sign in to comment.