Example #1
0
            public static bool WellKnownBlob(ILocalFileInfo blob)
            {
                // Ignore empty files
                if (blob.Size == 0)
                {
                    return(true);
                }

                if (blob.MD5 == "1B2M2Y8AsgTpgAmY7PhCfg==" && blob.Size < 1024 * 1024) // md5 same as 0 byte
                {
                    return(true);
                }

                // Ignore files only containing "[]"
                if (blob.Size == 2 && blob.MD5 == "11FxOYiYfpMxmANj4kGJzg==")
                {
                    return(true);
                }
                // Ignore files only containing "{}"
                if (blob.Size == 2 && blob.MD5 == "mZFLkyvTelC5g8XnyQrpOw==")
                {
                    return(true);
                }
                // Ignore files only containing "[\"\"]"
                if (blob.Size == 4 && blob.MD5 == "OZ/GZwhxR0zXzgRYQB/SmQ==")
                {
                    return(true);
                }

                return(false);
            }
Example #2
0
        public static string DiffString(this ILocalFileInfo x, ILocalFileInfo y)
        {
            var sb = new StringBuilder();

            sb.Append($"Exists: {x.Exists}");
            if (x.Exists != y.Exists)
            {
                sb.Append($" vs {y.Exists}");
            }

            sb.Append($", Size: {x.Size}");
            if (x.Size != y.Size)
            {
                sb.Append($" vs {y.Size}");
            }

            sb.Append($", MD5: {x.MD5}");
            if (x.MD5 != y.MD5)
            {
                sb.Append($" vs {y.MD5}");
            }

            sb.Append($", LasModifiedUtc: {x.LastModifiedTimeUtc}");
            if (x.LastModifiedTimeUtc != y.LastModifiedTimeUtc)
            {
                sb.Append($" vs {y.LastModifiedTimeUtc}");
            }

            return(sb.ToString());
        }
Example #3
0
 public static bool IsSame(this ILocalFileInfo x, ILocalFileInfo y)
 {
     return
         (x.Exists == y.Exists &&
          x.Size == y.Size &&
          x.MD5 == y.MD5 &&
          x.LastModifiedTimeUtc == y.LastModifiedTimeUtc &&
          true);
 }
Example #4
0
 internal FileInfo GetFileInfo(ILocalFileInfo lfi, string LocalName = null)
 {
     using (var reader = ExecuteReader("SELECT * FROM " + SQL_TABLENAME + " WHERE LocalName=@1", LocalName))
     {
         if (reader.Read())
         {
             return(new FileInfo(this, lfi, reader));
         }
     }
     return(null);
 }
Example #5
0
 internal void UpdateFromFileInfo(ILocalFileInfo fi)
 {
     if (fi == null || !fi.Exists)
     {
         return;
     }
     LastModifiedTime = fi.LastModifiedTimeUtc;
     Size             = fi.Size;
     if (!string.IsNullOrEmpty(fi.MD5))
     {
         MD5 = fi.MD5;
     }
 }
Example #6
0
            internal FileInfo(FileInfoSqlite sqlite, ILocalFileInfo fi, SQLiteDataReader reader)
                : this(sqlite)
            {
                SrcFileInfo      = fi;
                LocalName        = Convert.ToString(reader["LocalName"]);
                RemPath          = Convert.ToString(reader["RemPath"]);
                LastModifiedTime = Convert.ToDateTime(reader["LastModifiedTime"]);
                Size             = Convert.ToInt64(reader["Size"]);
                MD5 = Convert.ToString(reader["AzureMD5"]);
                LastDownloadedTime = GetDateTime(reader["LastDownloadedTime"]);
                DeleteDetectedTime = GetDateTime(reader["DeleteDetectedTime"]);

                // if there is local file, than it takes precedence over database values
                UpdateFromFileInfo(fi);
            }
Example #7
0
            public static bool WellKnownBlob(ILocalFileInfo blob)
            {
                // Ignore empty files
                if (blob.Size == 0)
                {
                    return(true);
                }

                if (blob.MD5 == "1B2M2Y8AsgTpgAmY7PhCfg==" && blob.Size < 1024 * 1024) // md5 same as 0 byte
                {
                    return(true);
                }

                // Ignore files only containing "[]"
                if (blob.Size == 2 && blob.MD5 == "11FxOYiYfpMxmANj4kGJzg==")
                {
                    return(true);
                }

                return(false);
            }
Example #8
0
        public ILocalFileInfo GetFileInfo(BlobItem blob, string localFilename = null)
        {
            ILocalFileInfo lfi = localFilename == null ? null : new LocalFileInfoDisk(localFilename);
            var            fi  = GetFileInfo(lfi, blob.GetLocalFileName());

            if (fi != null)
            {
                return(fi);
            }

            // create new instance
            ((LocalFileInfoDisk)lfi)?.GetMd5();
            fi = new FileInfo(this, lfi, blob);

            // make sure we insert item when there is nothing found
            ExecuteNonQuery("INSERT INTO " + SQL_TABLENAME +
                            " (LocalName, RemPath, LastModifiedTime, Size, AzureMD5, LastDownloadedTime, DeleteDetectedTime)" +
                            " VALUES (@1, @2, @3, @4, @5, @6, @7)",
                            fi.LocalName, fi.RemPath, fi.LastModifiedTime, fi.Size, fi.MD5, fi.LastDownloadedTime, fi.DeleteDetectedTime);

            return(fi);
        }
Example #9
0
 internal FileInfo(FileInfoSqlite sqlite, ILocalFileInfo fi, BlobItem blob)
     : this(sqlite, blob)
 {
     SrcFileInfo = fi;
     UpdateFromFileInfo(fi);
 }
Example #10
0
 private FileInfo(FileInfoSqlite sqlite, BlobItem blob)
     : this(sqlite)
 {
     SrcFileInfo = blob;
     UpdateFromAzure(blob);
 }