millis() _ Firebase _ SD

I have a problem with using the loop for a specific amount of time. For example: first I run the loop for 10 Sec, then I send the file to firebase and remove the file from SD.
I need to get the status from the server if it is needed to send the log or not. If yes, run my loop for 10 Sec and send the file, and make the status unneeded(0).

unsigned long timeS = 10000;
int n1 = 0;
int statusS = 0;
File myFile;

void loop() 
{
unsigned long currentMillis = millis();
while(currentMillis - previousMillis > timeS) 
{
  previousMillis = currentMillis;
  myFile = SD.open("/Log.txt", FILE_WRITE);
  myFile.println(millis());
  myFile.close();
  }

  if(currentMillis - previousMillis < timeS) 
  {
    if (Firebase.getInt(firebaseData, "/status /status ")) 
    {
      if (firebaseData.dataType() == "int") 
      {
        statusS = firebaseData.intData(); 
        Serial.print(statusS);
      }
    }
              
    if (statusS == 1)
    {
      if (Firebase.setFile(firebaseData, StorageType::SD, "/Log/Log", "/Log.txt"))
      {
        Serial.println("PASSED");
        Firebase.setInt(firebaseData, "/status /status " ,0);
        SD.remove("Log");
      }
      else
      {
        Serial.println("FAILED");
      }
    }
   }
}