Exemple #1
0
        private static DirContents FromDatabase(Credentials cr, MachineIdentity mid,
                                                DirIdentity did, bool downloadFilesContents = false)
        {
            List <FileContents> files = new List <FileContents>();
            var      c = cr.ToLib();
            var      m = mid.ToLib();
            DirModel d = did.ToLib();

            try {
                FileManipulator.GetFileList(c, m, d);

                foreach (FileModel f in d.Files)
                {
                    if (downloadFilesContents)
                    {
                        //adding contents to 'f'
                        FileManipulator.GetFileContent(c, m, d, f);
                    }
                    //adding new gui object to list
                    files.Add(new FileContents(f));
                }
            } catch (ActionException ex) {
                throw new ActionException("Unable to download directory contents.\n\n"
                                          + ex.Message + ".", ActionType.Directory, MemeType.Fuuuuu, ex);
            } catch (Exception ex) {
                throw new ActionException("Error while downloading directory contents.",
                                          ActionType.Directory, MemeType.Fuuuuu, ex);
            }

            //does not add local files, because this is supposed to happen in the constructor that
            // launches this static private method
            return(new DirContents(did, files, false));
        }