This commit is contained in:
mysticbbs 2013-09-24 04:40:46 -04:00
parent 4682194e48
commit edba0051c7
3 changed files with 103 additions and 44 deletions

View File

@ -67,6 +67,7 @@ Function IsThisUser (U: RecUser; Str: String) : Boolean;
// ECHOMAIL // ECHOMAIL
Function GetNodeByAddress (Addr: String; Var TempNode: RecEchoMailNode) : Boolean; Function GetNodeByAddress (Addr: String; Var TempNode: RecEchoMailNode) : Boolean;
Function GetFTNBundleExt (IncOnly: Boolean; Str: String) : String;
Implementation Implementation
@ -650,6 +651,44 @@ Begin
Close (F); Close (F);
End; End;
Function GetFTNBundleExt (IncOnly: Boolean; Str: String) : String;
Var
FN : String;
Ext : String;
Last : Byte;
First : Byte;
Begin
FN := JustFileName(Str);
Ext := strLower(JustFileExt(Str));
Last := Byte(Ext[Length(Ext)]);
If Not (Last in [48..57, 97..122]) Then Last := 48;
First := Last;
Repeat
Result := FN + '.' + Ext;
Result[Length(Result)] := Char(Last);
If IncOnly Then Begin
If First <> Last Then
Break;
End Else
If Not FileExist(Result) Then Break;
Inc (Last);
If Last = 58 Then Last := 97;
If Last = 123 Then Last := 48; // loop
If First = Last Then Begin
Result[Length(Result)] := Char(123);
Break;
End;
Until False;
End;
Initialization Initialization
bbsCfgStatus := GetBaseConfiguration(True, bbsCfg); bbsCfgStatus := GetBaseConfiguration(True, bbsCfg);

View File

@ -64,36 +64,35 @@ Begin
End; End;
End; End;
Function FindBundleName (Str: String) : String;
Var
FN : String;
Ext : String;
Last : Byte;
Begin
FN := JustFileName(Str);
Ext := strLower(JustFileExt(Str));
Last := Byte(Ext[Length(Ext)]);
If Not (Last in [48..57, 97..122]) Then Last := 48;
Repeat
Result := FN + '.' + Ext;
Result[Length(Result)] := Char(Last);
If Not FileExist(Result) Then Break;
Inc (Last);
If Last = 58 Then Last := 97;
If Last = 123 Then Exit; // no 0-9,a-z could be generated
Until False;
End;
Function PollNodeFTP (OnlyNew: Boolean; Var Queue: TProtocolQueue; Var EchoNode: RecEchoMailNode) : Boolean; Function PollNodeFTP (OnlyNew: Boolean; Var Queue: TProtocolQueue; Var EchoNode: RecEchoMailNode) : Boolean;
Var Var
FTP : TFTPClient; FTP : TFTPClient;
Count : LongInt;
Function ExistsOnServer (Str: String) : Boolean;
Var
Count : LongInt;
Begin
Result := False;
writeln ('debug checking exists ', str, ' files:', ftp.responsedata.count);
For Count := 1 to FTP.ResponseData.Count Do Begin
writeln('debug remote: ', FTP.ResponseData.Strings[Count - 1]);
If strUpper(JustFile(Str)) = strUpper(FTP.ResponseData.Strings[Count - 1]) Then Begin
Result := True;
Break;
End;
End;
End;
Var
Count : LongInt;
Count2 : LongInt;
OldFN : String;
NewFN : String;
IsDupe : Boolean;
Begin Begin
Result := False; Result := False;
@ -131,19 +130,40 @@ Begin
PrintStatus (NIL, 1, 'Unable to list ' + EchoNode.ftpInDir); PrintStatus (NIL, 1, 'Unable to list ' + EchoNode.ftpInDir);
If Queue.QSize > 0 Then Begin If Queue.QSize > 0 Then Begin
If FTP.ChangeDirectory(EchoNode.ftpOutDir) Then Begin If FTP.GetDirectoryList(EchoNode.ftpPassive, True, EchoNode.ftpOutDir) Then Begin
For Count := 1 to Queue.QSize Do Begin For Count := 1 to Queue.QSize Do Begin
PrintStatus (NIL, 1, 'Sending ' + Queue.QData[Count]^.FileNew); OldFN := Queue.QData[Count]^.FileNew;
NewFN := OldFN;
IsDupe := False;
If FTP.SendFile(EchoNode.ftpPassive, Queue.QData[Count]^.FilePath + Queue.QData[Count]^.FileName, Queue.QData[Count]^.FileNew) = ftpResOK Then Begin Repeat
// only remove by markings... or move to removefilesfromflo If ExistsOnServer(NewFN) Then Begin
FileErase (Queue.QData[Count]^.FilePath + Queue.QData[Count]^.FileName); NewFN := GetFTNBundleExt(True, NewFN);
RemoveFilesFromFLO (GetFTNOutPath(EchoNode), TempPath, Queue.QData[Count]^.FilePath + Queue.QData[Count]^.FileName);
End Else If NewFN = OldFN Then Begin
PrintStatus (NIL, 1, 'Failed'); IsDupe := True;
Break;
End;
End Else
Break;
Until False;
If IsDupe Then
PrintStatus (NIL, 1, 'Cannot send ' + OldFN + '; already exists')
Else Begin
PrintStatus (NIL, 1, 'Sending ' + OldFN + ' as ' + NewFN);
If FTP.SendFile(EchoNode.ftpPassive, Queue.QData[Count]^.FilePath + Queue.QData[Count]^.FileName, NewFN) = ftpResOK Then Begin
// only remove by markings... or move to removefilesfromflo
FileErase (Queue.QData[Count]^.FilePath + Queue.QData[Count]^.FileName);
RemoveFilesFromFLO (GetFTNOutPath(EchoNode), TempPath, Queue.QData[Count]^.FilePath + Queue.QData[Count]^.FileName);
End Else
PrintStatus (NIL, 1, 'Failed');
End;
End; End;
End Else End Else
PrintStatus (NIL, 1, 'Unable to change to ' + echoNode.ftpOutDir); PrintStatus (NIL, 1, 'Unable to list ' + EchoNode.ftpOutDir);
End; End;
End Else End Else
PrintStatus (NIL, 1, 'Unable to authenticate'); PrintStatus (NIL, 1, 'Unable to authenticate');
@ -181,7 +201,7 @@ Begin
For Count := 1 to Queue.QSize Do Begin For Count := 1 to Queue.QSize Do Begin
PKTName := Queue.QData[Count]^.FilePath + Queue.QData[Count]^.FileName; PKTName := Queue.QData[Count]^.FilePath + Queue.QData[Count]^.FileName;
NewName := FindBundleName(EchoNode.DirInDir + Queue.QData[Count]^.FileNew); NewName := GetFTNBundleExt(False, EchoNode.DirInDir + Queue.QData[Count]^.FileNew);
PrintStatus (NIL, 1, 'Move ' + PKTName + ' to ' + NewName); PrintStatus (NIL, 1, 'Move ' + PKTName + ' to ' + NewName);

View File

@ -92,6 +92,12 @@ Begin
FLOName := BundlePath + GetFTNFlowName(EchoNode.Address); FLOName := BundlePath + GetFTNFlowName(EchoNode.Address);
BundleName := BundlePath + GetFTNArchiveName(OrigAddr, EchoNode.Address) + '.' + strLower(DayString[DayOfWeek(CurDateDos)]); BundleName := BundlePath + GetFTNArchiveName(OrigAddr, EchoNode.Address) + '.' + strLower(DayString[DayOfWeek(CurDateDos)]);
BundleName[Length(BundleName)] := '0';
//check for filesize... and...
//force every bundle to increment
//BundleName := GetFTNBundleExt(BundlePath + GetFTNArchiveName(OrigAddr, EchoNode.Address) + '.' + Copy(strLower(DayString[DayOfWeek(CurDateDos)]), 1, 2) + '0');
Case EchoNode.MailType of Case EchoNode.MailType of
0 : FLOName := FLOName + '.flo'; 0 : FLOName := FLOName + '.flo';
1 : FLOName := FLOName + '.clo'; 1 : FLOName := FLOName + '.clo';
@ -99,12 +105,6 @@ Begin
3 : FLOName := FLOName + '.hlo'; 3 : FLOName := FLOName + '.hlo';
End; End;
// TODO
// check for existance, packet size limitations, etc and increment
// from 0-9 A-Z
BundleName[Length(BundleName)] := '0';
ExecuteArchive (TempPath, BundleName, EchoNode.ArcType, TempPath + PKTName, 1); ExecuteArchive (TempPath, BundleName, EchoNode.ArcType, TempPath + PKTName, 1);
FileErase (TempPath + PKTName); FileErase (TempPath + PKTName);
AddToFLOQueue (FLOName, BundleName); AddToFLOQueue (FLOName, BundleName);