Coder Social home page Coder Social logo

[Feature]: Show a warning when CKAN detects CKAN files for an identifier selected or being downloaded as a dependency that have a newer spec than the CKAN version about ckan HOT 2 OPEN

cheese3660 avatar cheese3660 commented on June 8, 2024
[Feature]: Show a warning when CKAN detects CKAN files for an identifier selected or being downloaded as a dependency that have a newer spec than the CKAN version

from ckan.

Comments (2)

HebaruSan avatar HebaruSan commented on June 8, 2024

When this happens, UnsupportedKraken is thrown by CkanModule.FromJson and handled here for freshly downloaded metadata:

if (exception is UnsupportedKraken || exception is BadMetadataKraken)
{
// Either of these can be caused by data meant for future
// clients, so they're not really warnings, they're just
// informational.
log.InfoFormat("Skipping {0}: {1}", filename, exception.Message);
// I'd *love a way to "return" from the catch block.
handled = true;
break;
}

There's also a JSON converter for when we load cached data from disk after saving it with a newer client:

  • [JsonProperty]
    [JsonConverter(typeof(JsonLeakySortedDictionaryConverter<ModuleVersion, CkanModule>))]
    internal SortedDictionary<ModuleVersion, CkanModule> module_version =
    new SortedDictionary<ModuleVersion, CkanModule>();
  • public class JsonLeakySortedDictionaryConverter<K, V> : JsonConverter
    {
    public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
    {
    var dict = new SortedDictionary<K, V>();
    foreach (var kvp in JObject.Load(reader))
    {
    try
    {
    dict.Add(
    (K)Activator.CreateInstance(typeof(K), kvp.Key),
    kvp.Value.ToObject<V>());
    }
    catch (Exception exc)
    {
    log.Warn($"Failed to deserialize {kvp.Key}: {kvp.Value}", exc);
    }
    }
    return dict;
    }

In both cases unsupported modules are noted in the log and then skipped because the older client can't handle them. To alert the user, we would have to propagate a message out to GUI in some way, and it's not obvious to me how we could do that.

from ckan.

HebaruSan avatar HebaruSan commented on June 8, 2024

Thinking about the code level interface for this, it might make sense to extend the enum that the repo update process returns:

/// <summary>
/// Values to describe the result of an attempted repository update.
/// Failure is actually handled by throwing exceptions, so I'm not sure we need that.
/// </summary>
public enum UpdateResult
{
Failed,
Updated,
NoChanges,
}

RepositoryDataMaanger could return a new OutdatedClient option if any unsupported modules are found, and GUI could use that as a signal to prompt the user to update their client, maybe with a yes/no dialog.

from ckan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.