Esempio n. 1
0
        public void UpdateSourceTags(BuildContext ctx, SourceInfo source, bool force)
        {
            if (!force && (DateTime.Now - source.LastFetchTime).TotalMinutes < 5)
            {
                return;
            }
            ctx.Server.SetSourceStatus(ctx.AppId, source.Id, SourceTagStatus.Fetching, "");
            try {
                List <SourceTagInfo> newTags = new List <SourceTagInfo> (source.SourceTags);
                HashSet <string>     newUrls = new HashSet <string> ();

                SourcePuller sp = VersionControl.GetSourcePuller(source.Type);
                foreach (SourceTagInfo st in sp.GetChildUrls(ctx, source))
                {
                    newUrls.Add(st.Url);
                    SourceTagInfo currentTag = source.GetSourceTag(st.Url);
                    if (currentTag == null)
                    {
                        st.Status = SourceTagStatus.Waiting;
                        newTags.Add(st);
                    }
                    else
                    {
                        if (currentTag.LastRevision != st.LastRevision)
                        {
                            source.CleanSources(ctx, currentTag);
                            currentTag.LastRevision = st.LastRevision;
                            currentTag.Status       = SourceTagStatus.Waiting;
                        }
                    }
                }
                foreach (SourceTagInfo st in source.SourceTags)
                {
                    if (!newUrls.Contains(st.Url))
                    {
                        newTags.Remove(st);
                    }
                }
                source.LastFetchTime = DateTime.Now;
                ctx.Server.UpdateSourceTags(ctx.AppId, source.Id, DateTime.Now, newTags.ToArray());
                ctx.Server.SetSourceStatus(ctx.AppId, source.Id, SourceTagStatus.Ready, "");
            }
            catch (Exception ex) {
                ctx.Server.SetSourceStatus(ctx.AppId, source.Id, SourceTagStatus.FetchError, ex.Message);
                ctx.Log(ex);
            }
        }
Esempio n. 2
0
        public void UpdateSourceTags(BuildContext ctx, SourceInfo source, bool force)
        {
            if (!force && (DateTime.Now - source.LastFetchTime).TotalMinutes < 5)
                return;
            ctx.Server.SetSourceStatus (ctx.AppId, source.Id, SourceTagStatus.Fetching, "");
            try {
                List<SourceTagInfo> newTags = new List<SourceTagInfo> (source.SourceTags);
                HashSet<string> newUrls = new HashSet<string> ();

                SourcePuller sp = VersionControl.GetSourcePuller (source.Type);
                foreach (SourceTagInfo st in sp.GetChildUrls (ctx, source)) {
                    newUrls.Add (st.Url);
                    SourceTagInfo currentTag = source.GetSourceTag (st.Url);
                    if (currentTag == null) {
                        st.Status = SourceTagStatus.Waiting;
                        newTags.Add (st);
                    }
                    else {
                        if (currentTag.LastRevision != st.LastRevision) {
                            source.CleanSources (ctx, currentTag);
                            currentTag.LastRevision = st.LastRevision;
                            currentTag.Status = SourceTagStatus.Waiting;
                        }
                    }
                }
                foreach (SourceTagInfo st in source.SourceTags) {
                    if (!newUrls.Contains (st.Url))
                        newTags.Remove (st);
                }
                source.LastFetchTime = DateTime.Now;
                ctx.Server.UpdateSourceTags (ctx.AppId, source.Id, DateTime.Now, newTags.ToArray ());
                ctx.Server.SetSourceStatus (ctx.AppId, source.Id, SourceTagStatus.Ready, "");
            }
            catch (Exception ex) {
                ctx.Server.SetSourceStatus (ctx.AppId, source.Id, SourceTagStatus.FetchError, ex.Message);
                ctx.Log (ex);
            }
        }