async function lookupProjectFile()

in frontend/app/PremiereVersionChange/VersionChangeService.ts [40:79]


async function lookupProjectFile(filePath: string): Promise<FileEntry> {
  try {
    let queryData: FileEntryFilterTerms = {
      filePath: getBasename(filePath),
      match: "W_EXACT",
    };

    //limit the storage query to the storage where primary projects should be.
    try {
      const defaultStorageId = await getProjectsDefaultStorageId();
      queryData.storageId = defaultStorageId;
    } catch (err) {
      if (err.response && err.response.status == 404) {
        console.warn(
          "There is no default storage set, so backups cannot be excluded. Consider setting a default project storage to improve reliability of this operation."
        );
      } else {
        throw err;
      }
    }

    const response = await axios.put<ObjectListResponse<FileEntry>>(
      "/api/file/list",
      queryData
    );
    if (response.data.count == 0) {
      return Promise.reject(
        "Could not find this project file in the system. Please report this error to Multimedia tech, along with the page URL above."
      );
    } else {
      const liveProjects = response.data.result.filter((f) => !f.backupOf);
      return liveProjects[0];
    }
  } catch (err) {
    console.error("Could not look up project file information: ", err);
    return Promise.reject(
      "There was a server error trying to find your project. Please try again in a few minutes."
    );
  }
}