Skip to content

Commit 91a21e8

Browse files
committed
Do not delete keys file if no entries are found
This is follow-up to #3545 It's assumed that if user drops keys file into ASF's config directory, their intention is to make use of that file in order to add something into ASF. While we filter it out and accept the fact that the file may not represent 1:1 ASF's required input, there should be at least one valid entry to assume that user knows what they're doing. Therefore, deleting the file outright is probably not a good idea, now that we have logging, it's better to leave file as-is and allow user to correct it. Of course, one could also argue that such correction is impossible if 1+ valid entries are found, but that's no longer our concern, user is expected to drop valid file there to begin with, and we're only adding logic for the most obvious kind of mistake, not all mistakes possible.
1 parent 355f053 commit 91a21e8

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

ArchiSteamFarm/Steam/Bot.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,18 +1490,22 @@ internal async Task ImportKeysToRedeem(string filePath) {
14901490
}
14911491
}
14921492

1493-
if (gamesToRedeemInBackground.Count > 0) {
1494-
FilterGamesToRedeemInBackground(gamesToRedeemInBackground);
1495-
1496-
if (gamesToRedeemInBackground.Count > 0) {
1497-
AddGamesToRedeemInBackground(gamesToRedeemInBackground);
1498-
} else {
1499-
ArchiLogger.LogGenericWarning(Strings.WarningNoValidKeysFound);
1500-
}
1501-
} else {
1493+
if (gamesToRedeemInBackground.Count == 0) {
15021494
ArchiLogger.LogGenericError(Strings.FormatErrorIsEmpty(filePath));
1495+
1496+
return;
15031497
}
15041498

1499+
FilterGamesToRedeemInBackground(gamesToRedeemInBackground);
1500+
1501+
if (gamesToRedeemInBackground.Count == 0) {
1502+
ArchiLogger.LogGenericWarning(Strings.WarningNoValidKeysFound);
1503+
1504+
return;
1505+
}
1506+
1507+
AddGamesToRedeemInBackground(gamesToRedeemInBackground);
1508+
15051509
File.Delete(filePath);
15061510
} catch (Exception e) {
15071511
ArchiLogger.LogGenericException(e);

0 commit comments

Comments
 (0)