<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Newtonsoft.Json;
using Duplicati.Library.Interface;

namespace Duplicati.Library.Main.Volumes
{
    public class FilesetVolumeWriter : VolumeWriterBase
    {
        private StreamWriter m_streamwriter;
        private readonly JsonWriter m_writer;
        private long m_filecount;
        private long m_foldercount;

        public override RemoteVolumeType FileType { get { return RemoteVolumeType.Files; } }

        public FilesetVolumeWriter(Options options, DateTime timestamp)
            : base(options, timestamp)
        {
            m_streamwriter = new StreamWriter(m_compression.CreateFile(FILELIST, CompressionHint.Compressible, DateTime.UtcNow));
            m_writer = new JsonTextWriter(m_streamwriter);
            m_writer.WriteStartArray();
        }

        private void WriteMetaProperties(string metahash, long metasize, string metablockhash, IEnumerable<string> metablocklisthashes)
        {
            m_writer.WritePropertyName("metahash");
            m_writer.WriteValue(metahash);
            m_writer.WritePropertyName("metasize");
            m_writer.WriteValue(metasize);

            if (metablocklisthashes != null)
            {
                //Slightly akward, but we avoid writing if there are no entries 
                var en = metablocklisthashes.GetEnumerator();
                if (en.MoveNext() && !string.IsNullOrEmpty(en.Current))
                {
                    m_writer.WritePropertyName("metablocklists");
                    m_writer.WriteStartArray();
                    m_writer.WriteValue(en.Current);
                    while (en.MoveNext())
                        m_writer.WriteValue(en.Current);
                    m_writer.WriteEndArray();<commit_msg>Dispose of manually enumerated enumerator.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Newtonsoft.Json;
using Duplicati.Library.Interface;

namespace Duplicati.Library.Main.Volumes
{
    public class FilesetVolumeWriter : VolumeWriterBase
    {
        private StreamWriter m_streamwriter;
        private readonly JsonWriter m_writer;
        private long m_filecount;
        private long m_foldercount;

        public override RemoteVolumeType FileType { get { return RemoteVolumeType.Files; } }

        public FilesetVolumeWriter(Options options, DateTime timestamp)
            : base(options, timestamp)
        {
            m_streamwriter = new StreamWriter(m_compression.CreateFile(FILELIST, CompressionHint.Compressible, DateTime.UtcNow));
            m_writer = new JsonTextWriter(m_streamwriter);
            m_writer.WriteStartArray();
        }

        private void WriteMetaProperties(string metahash, long metasize, string metablockhash, IEnumerable<string> metablocklisthashes)
        {
            m_writer.WritePropertyName("metahash");
            m_writer.WriteValue(metahash);
            m_writer.WritePropertyName("metasize");
            m_writer.WriteValue(metasize);

            if (metablocklisthashes != null)
            {
                //Slightly akward, but we avoid writing if there are no entries 
                using (var en = metablocklisthashes.GetEnumerator())
                {
                    if (en.MoveNext() && !string.IsNullOrEmpty(en.Current))
                    {
                        m_writer.WritePropertyName("metablocklists");
                        m_writer.WriteStartArray();
                        m_writer.WriteValue(en.Current);
                        while (en.MoveNext())
                            m_writer.WriteValue(en.Current);
                        m_writer.WriteEndArray();
                    }
{'fraction_non_alphanumeric': 0.0776495278069255, 'fraction_numerical': 0.0, 'mean_word_length': 2.2395921835174173, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4735325', 'n_tokens_mistral': 998, 'n_tokens_neox': 963, 'n_words': 198}