refactor writePackageNamesAndVersionToFile

This commit is contained in:
AustrianToast 2023-06-19 22:30:48 +02:00
parent dc811d7462
commit 5018856aab
No known key found for this signature in database
GPG Key ID: 5CD422268E489EB4

View File

@ -63,7 +63,10 @@ public class PacserverUtils {
}
public void writePackageNamesAndVersionToFile(string filePath) {
if (!File.Exists(filePath)) {
if (File.Exists(filePath)) {
File.Delete(filePath);
}
using (File.Open(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) {
using (StreamWriter sw = new StreamWriter(filePath)) {
foreach (string package in packageNamesAndVersion) {
@ -71,16 +74,6 @@ public class PacserverUtils {
}
}
}
} else if (File.Exists(filePath)) {
File.Delete(filePath);
using (File.Open(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) {
using (var sw = new StreamWriter(filePath)) {
foreach (string package in packageNamesAndVersion) {
sw.WriteLine(package);
}
}
}
}
}
public List<String> diffOfPackagesOrDatabases = new List<String>();