Esempio n. 1
0
        internal DropboxDeployInfo GetDeployInfo(string path, OAuthInfo oauth, AccountInfo account, string cursor = null)
        {
            List <DropboxEntryInfo> deltas = new List <DropboxEntryInfo>();
            string timeStamp = GetUtcTimeStamp();
            string oldCursor = cursor;
            string newCursor = "";

            while (true)
            {
                DeltaInfo delta = GetDeltaInfo(oauth, cursor);
                newCursor = delta.cursor;
                if (newCursor == oldCursor)
                {
                    break;
                }

                foreach (EntryInfo info in delta.entries)
                {
                    DropboxEntryInfo item = new DropboxEntryInfo();

                    if (info.metadata != null && !info.metadata.path.StartsWith(path))
                    {
                        continue;
                    }

                    if (info.metadata == null || info.metadata.is_deleted || string.IsNullOrEmpty(info.metadata.path))
                    {
                        item.Path      = info.path;
                        item.IsDeleted = true;
                    }
                    else
                    {
                        item.Path        = info.metadata.path;
                        item.IsDirectory = info.metadata.is_dir;
                        if (!item.IsDirectory)
                        {
                            item.Modified  = info.metadata.modified;
                            item.Nonce     = GetNonce();
                            item.Signature = GetSignature(oauth, info.path, timeStamp, item.Nonce);
                        }
                    }

                    deltas.Add(item);
                }

                if (!delta.has_more)
                {
                    break;
                }

                cursor = newCursor;
            }

            if (deltas.Count == 0)
            {
                throw new InvalidOperationException("the repo is up-to-date.");
            }

            var deployInfo = new DropboxDeployInfo
            {
                TimeStamp       = timeStamp,
                Token           = oauth.Token,
                ConsumerKey     = oauth.ConsumerKey,
                OAuthVersion    = "1.0",
                SignatureMethod = "HMAC-SHA1",
                OldCursor       = oldCursor,
                NewCursor       = newCursor,
                Path            = path,
                UserName        = account.display_name,
                Email           = account.email,
            };

            deployInfo.Deltas.AddRange(deltas);

            return(deployInfo);
        }
 void UpdateDeltaAxis(DeltaInfo delta)
 {
     //Debug.Log(delta.delta.ToString("F4").RichText().Bold().InGreen().ToString() + " " + delta.deltaNormalized.ToString("F2").RichText().Bold().InRed().ToString());
     OnUpdateDelta(delta);
 }