@@ -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