forked from eclipse/hawkbit
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix upload quota check and provide better error message (eclipse#893)
* Adjusted upload quota check to include file size and show proper error message Signed-off-by: Alexander Dobler <alexander.dobler3@bosch-si.com> * Fixed failing upload quota tests Signed-off-by: Alexander Dobler <alexander.dobler3@bosch-si.com> * Moved quota check to stream, fixed review findings Signed-off-by: Alexander Dobler <alexander.dobler3@bosch-si.com> * Added missing license header to QuotaInputStream Signed-off-by: Alexander Dobler <alexander.dobler3@bosch-si.com> * Reworked uploadLock, ensured error messages may be translated, review fixes Signed-off-by: Alexander Dobler <alexander.dobler3@bosch-si.com> * Added local artifactrepo to gitignore Signed-off-by: Alexander Dobler <alexander.dobler3@bosch-si.com> * Fixed sonar issues and assignment quota message Signed-off-by: Alexander Dobler <alexander.dobler3@bosch-si.com> * PR review fixes Signed-off-by: Alexander Dobler <alexander.dobler3@bosch-si.com> * Split quota exceptions, PR fixes Signed-off-by: Alexander Dobler <alexander.dobler3@bosch-si.com> * Removed left over conversion method in quota helper Signed-off-by: Alexander Dobler <alexander.dobler3@bosch-si.com> * Made conversion helper class final Signed-off-by: Alexander Dobler <alexander.dobler3@bosch-si.com>
- Loading branch information
1 parent
59a1e5b
commit c540f8c
Showing
43 changed files
with
477 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ target | |
.metadata | ||
.project | ||
.idea | ||
artifactrepo | ||
|
||
# Windows image file caches | ||
Thumbs.db | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...bit-repository-api/src/main/java/org/eclipse/hawkbit/repository/SizeConversionHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Copyright (c) 2019 Bosch Software Innovations GmbH and others. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.eclipse.hawkbit.repository; | ||
|
||
/** | ||
* Helper class that provides simple conversion of byte values to readable | ||
* strings | ||
*/ | ||
public final class SizeConversionHelper { | ||
|
||
private static final String KB = "KB"; | ||
private static final String MB = "MB"; | ||
|
||
// do not allow to create instances | ||
private SizeConversionHelper() { | ||
} | ||
|
||
/** | ||
* Convert byte values to human readable strings with units | ||
* | ||
* @param byteValue | ||
* Value to convert in bytes | ||
*/ | ||
public static String byteValueToReadableString(final long byteValue) { | ||
double outputValue = byteValue / 1024.0; | ||
String unit = KB; | ||
if (outputValue >= 1024) { | ||
outputValue = outputValue / 1024.0; | ||
unit = MB; | ||
} | ||
// We cut decimal places to avoid localization handling | ||
return (long) outputValue + " " + unit; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.