예제 #1
0
        public async Task AvailableSpace(GoogleDriveService gd, Action action)
        {
            var spaceBefore = await gd.AvailableSpaceGoogleDrive();

            _logger.Info($"Avalible: {(float)spaceBefore / (1024 * 1024)} mb.");
            action();
            var spaceAfter = await gd.AvailableSpaceGoogleDrive();

            var cleaned = spaceAfter - spaceBefore;

            _logger.Info($"Cleaned: {cleaned} b.");
            _logger.Info($"Avalible: {(float)spaceAfter / (1024 * 1024)} mb.");
        }
예제 #2
0
        private async Task <GoogleDriveService> GoogleDriveService(long memory)
        {
begin:
            var key = _keys.FirstOrDefault();

            if (key == null)
            {
                var msg = "No avalible keys.";
                _logger.Error(msg);
                throw new Exception(msg);
            }
            var gd = new GoogleDriveService(_logger, key);

            var space = await gd.AvailableSpaceGoogleDrive();

            _logger.Info($"There are {(float)space/(1024*1024)} avalible mb at google drive.");
            if (space < memory + 10 * 1024 * 1024) // memory + additional 10mb
            {
                _keys.RemoveAt(0);
                goto begin;
            }

            return(gd);
        }