mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-02-04 07:20:39 +00:00
Fix Hetzner size storage
This commit is contained in:
parent
6f5ffa0f80
commit
5f13be9339
|
@ -150,7 +150,7 @@ class HetznerApi extends ServerProviderApi with VolumeProviderApi {
|
|||
final List<dynamic> rawVolumes = dbGetResponse.data['volumes'];
|
||||
for (final rawVolume in rawVolumes) {
|
||||
final int dbId = rawVolume['id'];
|
||||
final int dbSize = rawVolume['size'];
|
||||
final int dbSize = rawVolume['size'] * 1024 * 1024 * 1024;
|
||||
final dbServer = rawVolume['server'];
|
||||
final String dbName = rawVolume['name'];
|
||||
final dbDevice = rawVolume['linux_device'];
|
||||
|
|
|
@ -3,12 +3,26 @@ import 'package:easy_localization/easy_localization.dart';
|
|||
class DiskSize {
|
||||
const DiskSize({final this.byte = 0});
|
||||
|
||||
DiskSize.fromKibibyte(final double kibibyte)
|
||||
: this(byte: (kibibyte * 1024).round());
|
||||
DiskSize.fromMebibyte(final double mebibyte)
|
||||
: this(byte: (mebibyte * 1024 * 1024).round());
|
||||
DiskSize.fromGibibyte(final double gibibyte)
|
||||
: this(byte: (gibibyte * 1024 * 1024 * 1024).round());
|
||||
|
||||
final int byte;
|
||||
|
||||
double get kibibyte => byte / 1024.0;
|
||||
double get mebibyte => byte / 1024.0 / 1024.0;
|
||||
double get gibibyte => byte / 1024.0 / 1024.0 / 1024.0;
|
||||
|
||||
DiskSize operator +(final DiskSize other) =>
|
||||
DiskSize(byte: byte + other.byte);
|
||||
DiskSize operator -(final DiskSize other) =>
|
||||
DiskSize(byte: byte - other.byte);
|
||||
DiskSize operator *(final double other) =>
|
||||
DiskSize(byte: (byte * other).round());
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (byte < 1024) {
|
||||
|
|
|
@ -78,7 +78,8 @@ class DiskStatus {
|
|||
continue;
|
||||
}
|
||||
|
||||
final String deviceId = iterableProviderVolume.linuxDevice!.split('/').last;
|
||||
final String deviceId =
|
||||
iterableProviderVolume.linuxDevice!.split('/').last;
|
||||
if (deviceId.contains(volume.model!) &&
|
||||
deviceId.contains(volume.serial!)) {
|
||||
providerVolume = iterableProviderVolume;
|
||||
|
@ -86,8 +87,8 @@ class DiskStatus {
|
|||
}
|
||||
}
|
||||
|
||||
final DiskVolume diskVolume = DiskVolume.fromServerDiscVolume(volume, providerVolume);
|
||||
|
||||
final DiskVolume diskVolume =
|
||||
DiskVolume.fromServerDiscVolume(volume, providerVolume);
|
||||
|
||||
return diskVolume;
|
||||
}).toList();
|
||||
|
|
|
@ -24,7 +24,7 @@ class ExtendingVolumePage extends StatefulWidget {
|
|||
class _ExtendingVolumePageState extends State<ExtendingVolumePage> {
|
||||
@override
|
||||
void initState() {
|
||||
minSize = widget.diskVolumeToResize.sizeTotal;
|
||||
minSize = widget.diskVolumeToResize.sizeTotal + DiskSize.fromGibibyte(2);
|
||||
_currentSliderGbValue = minSize.gibibyte;
|
||||
super.initState();
|
||||
}
|
||||
|
@ -70,7 +70,8 @@ class _ExtendingVolumePageState extends State<ExtendingVolumePage> {
|
|||
_priceController.text =
|
||||
(_euroPerGb * double.parse(_sizeController.text))
|
||||
.toStringAsFixed(2);
|
||||
minSize = widget.diskVolumeToResize.sizeTotal;
|
||||
minSize =
|
||||
widget.diskVolumeToResize.sizeTotal + DiskSize.fromGibibyte(2);
|
||||
if (_currentSliderGbValue < 0) {
|
||||
_currentSliderGbValue = minSize.gibibyte;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue