• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

HicServices / RDMP / 6403773653

04 Oct 2023 08:56AM UTC coverage: 56.913% (-0.1%) from 57.013%
6403773653

push

github

web-flow
Remove old Plugin object bits, tidy up (#1636)

* Remove old Plugin object bits, tidy up

* Purge remaining bits of AllExpiredPluginsNode

* Fix plugin display name in tree

* Update CreateNewDataExtractionProjectUI.cs

Casting fix

* Feature/rdmp42 delete plugins (#1642)

* add ui plugin delete functionality

* Warning and inheritance redundancy cleanups

* Narrow scope of catch clause per CodeQL warning

* Tidy Plugin name retrieval

---------

Co-authored-by: James A Sutherland <>
Co-authored-by: James Friel <jfriel001@dundee.ac.uk>

10690 of 20217 branches covered (0.0%)

Branch coverage included in aggregate %.

21 of 21 new or added lines in 6 files covered. (100.0%)

30535 of 52218 relevant lines covered (58.48%)

7323.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

2.08
/Rdmp.Core/Curation/Data/LoadModuleAssembly.cs
1
// Copyright (c) The University of Dundee 2018-2019
2
// This file is part of the Research Data Management Platform (RDMP).
3
// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4
// RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5
// You should have received a copy of the GNU General Public License along with RDMP. If not, see <https://www.gnu.org/licenses/>.
6

7
using System;
8
using System.Collections.Generic;
9
using System.IO;
10
using System.Linq;
11
using System.Threading;
12
using ICSharpCode.SharpZipLib.Zip;
13

14
namespace Rdmp.Core.Curation.Data;
15

16
/// <summary>
17
/// This entity wraps references to plugin .nupkg files on disk.
18
/// </summary>
19
public sealed class LoadModuleAssembly
20
{
21
    internal static readonly List<LoadModuleAssembly> Assemblies=new();
4✔
22
    private readonly FileInfo _file;
23

24
    private LoadModuleAssembly(FileInfo file)
×
25
    {
26
        _file = file;
×
27
    }
×
28

29
    /// <summary>
30
    /// Unpack the plugin DLL files, excluding any Windows UI specific dlls when not running a Windows GUI
31
    /// </summary>
32
    internal static IEnumerable<ValueTuple<string, MemoryStream>> GetContents(string path)
33
    {
34
        var info = new FileInfo(path);
×
35
        if (!info.Exists || info.Length < 100) yield break; // Ignore missing or empty files
×
36

37
        var pluginStream = info.OpenRead();
×
38
        Assemblies.Add(new LoadModuleAssembly(info));
×
39

40
        var isWin = AppDomain.CurrentDomain.GetAssemblies()
×
41
            .Any(static a => a.FullName?.StartsWith("Rdmp.UI", StringComparison.Ordinal) == true);
×
42

43
        if (!pluginStream.CanSeek)
×
44
            throw new ArgumentException("Seek needed", nameof(path));
×
45

46
        using var zip = new ZipFile(pluginStream);
×
47
        foreach (var e in zip.Cast<ZipEntry>()
×
48
                     .Where(static e => e.IsFile && e.Name.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
×
49
                     .Where(e => isWin || !e.Name.Contains("/windows/")))
×
50
        {
51
            using var s = zip.GetInputStream(e);
×
52
            using var ms2 = new MemoryStream();
×
53
            s.CopyTo(ms2);
×
54
            ms2.Position = 0;
×
55
            yield return (e.Name, ms2);
×
56
        }
×
57
    }
×
58

59
    /// <summary>
60
    /// Copy the plugin nupkg to the given directory
61
    /// </summary>
62
    /// <param name="downloadDirectory"></param>
63
    public string DownloadAssembly(DirectoryInfo downloadDirectory)
64
    {
65
        if (!downloadDirectory.Exists)
×
66
            downloadDirectory.Create();
×
67
        var targetFile=Path.Combine(downloadDirectory.FullName, _file.Name);
×
68
        _file.CopyTo(targetFile,true);
×
69
        return targetFile;
×
70
    }
71

72
    public void Delete() => _file.Delete();
×
73
    public override string ToString() => _file.Name;
×
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc