protected void OnFileFetchEnded(UpdateFileStatus status)
 {
     if (FileFetchEnded != null)
     {
         FileFetchEnded(this, status);
     }
 }
 protected void OnFileRemoved(UpdateFileStatus status)
 {
     if (FileRemoved != null)
     {
         FileRemoved(this, status);
     }
 }
Beispiel #3
0
 // Called from the worker thread
 public void HandleFileFetchEnded(object sender, UpdateFileStatus status)
 {
     SetStatusText("Downloaded File: " + status.file);
     lock (this) {
         bytesFetched += status.length;
     }
     UpdateProgress();
 }
 // Called from the worker thread
 public void HandleFileFetchEnded(object sender, UpdateFileStatus status)
 {
     SetStatusText("Downloaded File: " + status.file);
     lock (this) {
         bytesFetched += status.length;
     }
     UpdateProgress();
 }
 private static void HandleFileRemoved(object sender, UpdateFileStatus msg)
 {
     Console.WriteLine("Removed file: " + msg.file);
 }
 private static void HandleFileFetchEnded(object sender, UpdateFileStatus msg)
 {
     Console.WriteLine("Downloaded File: " + msg.file);
 }
 private static void HandleFileFetchStarted(object sender, UpdateFileStatus msg)
 {
     Console.WriteLine("Downloading File: " + msg.file + " ...");
 }
        public void ProcessManifest(string currentManifest)
        {
            if (currentManifest != null)
            {
                ReadManifest(currentManifestDict, currentManifest);
            }

            OnStateChanged(UpdateState.FetchingManifest);
            string baseDir = "";

            FileFetcher.FetchFile("MANIFEST", sourceUrl, baseDir);

            ReadManifest(targetManifestDict, "MANIFEST");

            long          bytesNeeded   = 0;
            int           filesNeeded   = 0;
            List <string> newFiles      = new List <string>();
            List <string> removedFiles  = new List <string>();
            List <string> modifiedFiles = new List <string>();

            foreach (string key in targetManifestDict.Keys)
            {
                long bytes = long.Parse(targetManifestDict[key].length);
                if (!currentManifestDict.ContainsKey(key))
                {
                    newFiles.Add(key);
                    bytesNeeded += bytes;
                    filesNeeded++;
                }
                else if (currentManifestDict[key].digest != targetManifestDict[key].digest)
                {
                    modifiedFiles.Add(key);
                    bytesNeeded += bytes;
                    filesNeeded++;
                }
            }
            foreach (string key in currentManifestDict.Keys)
            {
                if (!targetManifestDict.ContainsKey(key))
                {
                    removedFiles.Add(key);
                }
            }

            // At this point, we are about to start fetching new files,
            // so remove our existing manifest.  This will cause us to
            // do a full scan if our download is interrupted, which will
            // be more efficient than fetching everything again.
            File.Delete(currentManifest);

            UpdaterStatus updateStatus = new UpdaterStatus();

            updateStatus.files = filesNeeded;
            updateStatus.bytes = bytesNeeded;
            OnUpdateStarted(updateStatus);
            OnStateChanged(UpdateState.UpdatingFiles);
            foreach (string file in newFiles)
            {
                UpdateFileStatus ufs = new UpdateFileStatus();
                ufs.file   = file;
                ufs.length = long.Parse(targetManifestDict[file].length);
                OnFileFetchStarted(ufs);
                FileFetcher.FetchFile(file, sourceUrl, baseDir);
                OnFileFetchEnded(ufs);
            }
            foreach (string file in modifiedFiles)
            {
                UpdateFileStatus ufs = new UpdateFileStatus();
                ufs.file   = file;
                ufs.length = long.Parse(targetManifestDict[file].length);
                OnFileFetchStarted(ufs);
                FileFetcher.FetchFile(file, sourceUrl, baseDir);
                OnFileFetchEnded(ufs);
            }
            foreach (string file in removedFiles)
            {
                UpdateFileStatus ufs = new UpdateFileStatus();
                ufs.file = file;
                File.Delete(file);
                OnFileRemoved(ufs);
            }
            File.Copy("MANIFEST", "MANIFEST.cur");

            OnUpdateCompleted(updateStatus);
            OnStateChanged(UpdateState.UpdateEnded);
        }
 protected void OnFileRemoved(UpdateFileStatus status)
 {
     if (FileRemoved != null)
         FileRemoved(this, status);
 }
 protected void OnFileFetchStarted(UpdateFileStatus status)
 {
     if (FileFetchStarted != null)
         FileFetchStarted(this, status);
 }
        public void ProcessManifest(string currentManifest)
        {
            if (currentManifest != null)
                ReadManifest(currentManifestDict, currentManifest);

            OnStateChanged(UpdateState.FetchingManifest);
            string baseDir = "";
            FileFetcher.FetchFile("MANIFEST", sourceUrl, baseDir);

            ReadManifest(targetManifestDict, "MANIFEST");

            long bytesNeeded = 0;
            int filesNeeded = 0;
            List<string> newFiles = new List<string>();
            List<string> removedFiles = new List<string>();
            List<string> modifiedFiles = new List<string>();
            foreach (string key in targetManifestDict.Keys) {
                long bytes = long.Parse(targetManifestDict[key].length);
                if (!currentManifestDict.ContainsKey(key)) {
                    newFiles.Add(key);
                    bytesNeeded += bytes;
                    filesNeeded++;
                } else if (currentManifestDict[key].digest != targetManifestDict[key].digest) {
                    modifiedFiles.Add(key);
                    bytesNeeded += bytes;
                    filesNeeded++;
                }
            }
            foreach (string key in currentManifestDict.Keys) {
                if (!targetManifestDict.ContainsKey(key))
                    removedFiles.Add(key);
            }

            // At this point, we are about to start fetching new files,
            // so remove our existing manifest.  This will cause us to
            // do a full scan if our download is interrupted, which will
            // be more efficient than fetching everything again.
            File.Delete(currentManifest);

            UpdaterStatus updateStatus = new UpdaterStatus();
            updateStatus.files = filesNeeded;
            updateStatus.bytes = bytesNeeded;
            OnUpdateStarted(updateStatus);
            OnStateChanged(UpdateState.UpdatingFiles);
            foreach (string file in newFiles) {
                UpdateFileStatus ufs = new UpdateFileStatus();
                ufs.file = file;
                ufs.length = long.Parse(targetManifestDict[file].length);
                OnFileFetchStarted(ufs);
                FileFetcher.FetchFile(file, sourceUrl, baseDir);
                OnFileFetchEnded(ufs);
            }
            foreach (string file in modifiedFiles) {
                UpdateFileStatus ufs = new UpdateFileStatus();
                ufs.file = file;
                ufs.length = long.Parse(targetManifestDict[file].length);
                OnFileFetchStarted(ufs);
                FileFetcher.FetchFile(file, sourceUrl, baseDir);
                OnFileFetchEnded(ufs);
            }
            foreach (string file in removedFiles) {
                UpdateFileStatus ufs = new UpdateFileStatus();
                ufs.file = file;
                File.Delete(file);
                OnFileRemoved(ufs);
            }
            File.Copy("MANIFEST", "MANIFEST.cur");

            OnUpdateCompleted(updateStatus);
            OnStateChanged(UpdateState.UpdateEnded);
        }
Beispiel #12
0
 // Called from the worker thread
 public void HandleFileFetchStarted(object sender, UpdateFileStatus status)
 {
     SetStatusText("Downloading File: " + status.file + " ...");
     UpdateProgress();
 }
Beispiel #13
0
 // Called from the worker thread
 public void HandleFileRemoved(object sender, UpdateFileStatus status)
 {
     SetStatusText("Removed file: " + status.file);
     UpdateProgress();
 }
 // Called from the worker thread
 public void HandleFileRemoved(object sender, UpdateFileStatus status)
 {
     SetStatusText("Removed file: " + status.file);
     UpdateProgress();
 }
 // Called from the worker thread
 public void HandleFileFetchStarted(object sender, UpdateFileStatus status)
 {
     SetStatusText("Downloading File: " + status.file + " ...");
     UpdateProgress();
 }