Beispiel #1
0
        /// <summary>
        /// get the list of files in the specified bucket.
        /// </summary>
        /// <param name="bucketid"></param>
        /// <returns></returns>
        public IReadOnlyList <BUCommon.FreezeFile> getFiles(BUCommon.Container cont)
        {
            List <BUCommon.FreezeFile> list = new List <BUCommon.FreezeFile>();

            B2Net.Models.B2FileList files = null;
            string startfile = null;

            do
            {
                files = _client.Files.GetList(startfile, null, cont.id).Result;
                foreach (var f in files.Files)
                {
                    BUCommon.Hash h = null;
                    try {
                        h = BUCommon.Hash.FromString("SHA1", f.ContentSHA1);
                    } catch (FormatException fe)
                    {
                        h = BUCommon.Hash.Create("", new byte[] {});
                    }

                    var ff = new BUCommon.FreezeFile
                    {
                        path          = f.FileName
                        , uploaded    = f.UploadTimestampDate
                        , fileID      = f.FileId
                        , storedHash  = h
                        , mimeType    = f.ContentType
                        , serviceInfo = f.Action
                        , container   = cont
                    };

                    if (f.FileInfo.ContainsKey(LAST_MOD_MILLIS))
                    {
                    }
                    if (f.FileInfo.ContainsKey(LOCALHASH))
                    {
                        ff.enchash = f.FileInfo[LOCALHASH];
                    }

                    list.Add(ff);
                }
                startfile = files.NextFileName;
            } while (startfile != null);

            return(list);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cont"></param>
        /// <returns></returns>
        public IReadOnlyList <BUCommon.FreezeFile> getVersions(BUCommon.Container cont)
        {
            List <BUCommon.FreezeFile> list = new List <BUCommon.FreezeFile>();

            B2Net.Models.B2FileList files = null;
            string startfile   = null;
            string startfileID = null;

            do
            {
                files       = _client.Files.GetVersions(startfile, null, null, cont.id).Result;
                startfile   = files.NextFileName;
                startfileID = files.NextFileId;

                foreach (var f in files.Files)
                {
                    var ff = new BUCommon.FreezeFile
                    {
                        path          = f.FileName
                        , uploaded    = f.UploadTimestampDate
                        , mimeType    = f.ContentType
                        , fileID      = f.FileId
                        , storedHash  = BUCommon.Hash.FromString("SHA1", f.ContentSHA1)
                        , container   = cont
                        , serviceInfo = f.Action
                    };

                    if (f.FileInfo.ContainsKey(LAST_MOD_MILLIS))
                    {
                    }
                    if (f.FileInfo.ContainsKey(LOCALHASH))
                    {
                        ff.enchash = f.FileInfo[LOCALHASH];
                    }

                    list.Add(ff);
                }
            } while (startfile != null);

            return(list);
        }