From 8fc30c7d0fd5f69349499a7453abdcfce8af47a9 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Wed, 4 Apr 2012 23:45:20 +0100 Subject: [PATCH] repo: basic support for quota detection --- SparkleLib/Git/SparkleRepoGit.cs | 6 ++++++ SparkleLib/Makefile.am | 1 + SparkleLib/SparkleExceptions.cs | 37 ++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 SparkleLib/SparkleExceptions.cs diff --git a/SparkleLib/Git/SparkleRepoGit.cs b/SparkleLib/Git/SparkleRepoGit.cs index 43188491..f4752b73 100644 --- a/SparkleLib/Git/SparkleRepoGit.cs +++ b/SparkleLib/Git/SparkleRepoGit.cs @@ -221,6 +221,12 @@ namespace SparkleLib.Git { number = (number / 100 * 20); } else { + if (line.StartsWith ("ERROR: QUOTA EXCEEDED")) { + int quota_limit = int.Parse (line.Substring (21).Trim ()); + throw new QuotaExceededException ("Quota exceeded", quota_limit); + } + + // "Writing objects" stage number = (number / 100 * 80 + 20); diff --git a/SparkleLib/Makefile.am b/SparkleLib/Makefile.am index 68ab3755..81df077a 100755 --- a/SparkleLib/Makefile.am +++ b/SparkleLib/Makefile.am @@ -7,6 +7,7 @@ SOURCES = \ SparkleBackend.cs \ SparkleChangeSet.cs \ SparkleConfig.cs \ + SparkleExceptions.cs \ SparkleExtensions.cs \ SparkleFetcherBase.cs \ SparkleHelpers.cs \ diff --git a/SparkleLib/SparkleExceptions.cs b/SparkleLib/SparkleExceptions.cs new file mode 100644 index 00000000..78e24d9c --- /dev/null +++ b/SparkleLib/SparkleExceptions.cs @@ -0,0 +1,37 @@ +// SparkleShare, a collaboration and sharing tool. +// Copyright (C) 2010 Hylke Bons +// +// This program 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. +// +// This program 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. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + + +using System; + +namespace SparkleLib { + + public class QuotaExceededException : Exception { + + public readonly int QuotaLimit = -1; + + + public QuotaExceededException () + { + } + + + public QuotaExceededException (string message, int quota_limit) : base (message) + { + QuotaLimit = quota_limit; + } + } +}