Beispiel #1
0
        protected internal void GenerateAppDaos(string dbJsRoot, AppConf appConf, DirectoryInfo appDaoDir, string fileSearchPattern)
        {
            DirectoryInfo daoTemp = appConf.AppRoot.GetDirectory(Path.Combine(dbJsRoot, "appdaotmp_".RandomLetters(4)));

            // get the saved hashes to determine if changes were made
            string hashPath = GetHashFilePath(appDaoDir);
            List <FileContentHash> hashes = GetHashes(hashPath);

            //      generate app dao from *.db.js ~a:/dao/
            FileInfo[] dbJsFiles = appConf.AppRoot.GetFiles(dbJsRoot, fileSearchPattern);
            //      compile into ~a:/dao/bin
            dbJsFiles.Each(dbJs =>
            {
                string path = dbJs.FullName.ToLowerInvariant();
                FileContentHash currentHash = new FileContentHash(path);

                if (!hashes.Contains(currentHash) && appConf.CheckDaoHashes)
                {
                    FileContentHash remove = hashes.Where(h => h.FilePath.ToLowerInvariant().Equals(path)).FirstOrDefault();
                    if (remove != null)
                    {
                        hashes.Remove(remove);
                    }
                    hashes.Add(currentHash);
                    hashes.ToArray().ToJsonFile(hashPath);
                    GenerateAppDao(appConf.Name, appDaoDir, daoTemp, dbJs);
                }
                else if (!appConf.CheckDaoHashes)
                {
                    GenerateAppDao(appConf.Name, appDaoDir, daoTemp, dbJs);
                }
            });
        }
Beispiel #2
0
        private void GenerateCommonDao(string dbjsRoot, DirectoryInfo daoBinDir, string fileSearchPattern)
        {
            DirectoryInfo dbjsRootDir = BamConf.Fs.GetDirectory(dbjsRoot);
            DirectoryInfo daoTemp     = BamConf.Fs.GetDirectory(Path.Combine(dbjsRoot, "commondaotmp_".RandomLetters(4)));

            string hashPath = GetHashFilePath(dbjsRootDir);
            List <FileContentHash> hashes = GetHashes(hashPath);

            FileInfo[] dbJsFiles = BamConf.Fs.GetFiles(dbjsRoot, fileSearchPattern);
            dbJsFiles.Each(dbJs =>
            {
                string path = dbJs.FullName.ToLowerInvariant();
                FileContentHash currentHash = new FileContentHash(path);

                if (!hashes.Contains(currentHash))
                {
                    FileContentHash remove = hashes.Where(h => h.FilePath.ToLowerInvariant().Equals(path)).FirstOrDefault();
                    if (remove != null)
                    {
                        hashes.Remove(remove);
                    }
                    hashes.Add(currentHash);
                    hashes.ToArray().ToJsonFile(hashPath);

                    GenerateCommonDao(daoBinDir, daoTemp, dbJs);
                }
            });
        }
Beispiel #3
0
        public override bool Equals(object obj)
        {
            FileContentHash hash = obj as FileContentHash;

            if (hash != null)
            {
                return(hash.FilePath.Equals(this.FilePath) && hash.Sha1.Equals(this.Sha1));
            }
            else
            {
                return(base.Equals(obj));
            }
        }