Skip to content

Commit 82b879a

Browse files
fix: issue GerryFerdinandus#17 program opened by dragging a file
Default parameter does not work any more because we need 2 paramater to start the program in console mode.
1 parent 141cf72 commit 82b879a

File tree

2 files changed

+47
-25
lines changed

2 files changed

+47
-25
lines changed

enduser/readme.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ These '.txt' files must be place in the same directory as the program.
77

88
Console mode:
99
Start program with a parameter to torrent file or dir
10-
trackereditor.exe "C:\dir\torrent\file.torrent"
11-
trackereditor.exe "C:\dir\torrent"
10+
trackereditor.exe "C:\dir\torrent\file.torrent" -U4
11+
trackereditor.exe "C:\dir\torrent" -U4
1212
What tracker will be added/removed depend the content of the add_trackers.txt and remove_trackers.txt files.
1313

1414
--------------------
@@ -64,7 +64,7 @@ no new tracker + remove some or all tracker inside torrent.
6464
--------------------
6565

6666
Updated torrent file trackers list order with '-Ux' parameter.
67-
This is optional parameter. The default setting is -U4. The same as previous software version.
67+
This is a mandatory parameter.
6868

6969
trackereditor.exe "C:\dir\torrent" -U0
7070

source/code/main.pas

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -774,13 +774,17 @@ procedure TFormTrackerModify.ConsoleMode;
774774
//update the torrent via console mode if there is a parameter detected.
775775
if ParamCount > 0 then
776776
begin
777-
FConcoleMode := True;
777+
//there must be 2 command line items for console mode
778+
FConcoleMode := ParamCount = 2;
778779

779-
//Create the log file. The old one will be overwritten
780-
AssignFile(FLogFile, ExtractFilePath(Application.ExeName) + LOG_FILE_NAME);
781-
ReWrite(FLogFile);
780+
if FConcoleMode then
781+
begin
782+
//Create the log file. The old one will be overwritten
783+
AssignFile(FLogFile, ExtractFilePath(Application.ExeName) + LOG_FILE_NAME);
784+
ReWrite(FLogFile);
785+
end;
782786

783-
//Get the console parameters.
787+
//Get the startup command lime parameters.
784788
ConsoleModeDecodeParameter(FileNameOrDirStr);
785789

786790
//If FLogStringList empty then there is no error.
@@ -798,8 +802,13 @@ procedure TFormTrackerModify.ConsoleMode;
798802
CheckedOnOffAllTrackers(True);
799803
//Some tracker must be removed. Console and windows mode.
800804
UpdateViewRemoveTracker;
801-
//update torrent
802-
UpdateTorrent;
805+
806+
if FConcoleMode then
807+
begin
808+
//update torrent
809+
UpdateTorrent;
810+
end;
811+
803812
end;
804813
end
805814
else //a torrent file is selected?
@@ -810,16 +819,25 @@ procedure TFormTrackerModify.ConsoleMode;
810819
try
811820
//Convert Filenames to stringlist format.
812821
StringList.Add(FileNameOrDirStr);
813-
AddTorrentFileList(StringList);
814-
815-
//Show all the tracker inside the torrent files.
816-
ShowTrackerInsideFileList;
817-
//Mark all trackers as selected
818-
CheckedOnOffAllTrackers(True);
819-
//Some tracker must be removed. Console and windows mode.
820-
UpdateViewRemoveTracker;
821-
//update torrent
822-
UpdateTorrent;
822+
823+
//Extract all the trackers inside the torrent file
824+
if AddTorrentFileList(StringList) then
825+
begin
826+
//Show all the tracker inside the torrent files.
827+
ShowTrackerInsideFileList;
828+
//Mark all trackers as selected
829+
CheckedOnOffAllTrackers(True);
830+
//Some tracker must be removed. Console and windows mode.
831+
UpdateViewRemoveTracker;
832+
833+
if FConcoleMode then
834+
begin
835+
//update torrent
836+
UpdateTorrent;
837+
end;
838+
839+
end;
840+
823841
finally
824842
StringList.Free;
825843
end;
@@ -831,12 +849,16 @@ procedure TFormTrackerModify.ConsoleMode;
831849
end;
832850
end;
833851

834-
//Write to log file. And close the file.
835-
WriteLn(FLogFile, FLogStringList.Text);
836-
CloseFile(FLogFile);
852+
if FConcoleMode then
853+
begin
854+
//Write to log file. And close the file.
855+
WriteLn(FLogFile, FLogStringList.Text);
856+
CloseFile(FLogFile);
857+
858+
//Shutdown the console program
859+
Application.terminate;
860+
end;
837861

838-
//Shutdown the console program
839-
Application.terminate;
840862
end
841863
else
842864
begin //the program

0 commit comments

Comments
 (0)