Отправка файла в фэху @param area @param attach @param description
(Filearea area, File attach, String filename, String description)
| 1592 | * @param description |
| 1593 | */ |
| 1594 | public static void hatchFile(Filearea area, File attach, String filename, |
| 1595 | String description) { |
| 1596 | Filemail mail = new Filemail(); |
| 1597 | mail.setFilearea(area); |
| 1598 | mail.setFiledesc(description); |
| 1599 | mail.setFilename(filename); |
| 1600 | mail.setCreated(new Date()); |
| 1601 | mail.setOrigin(getPrimaryFtnAddress().toString()); |
| 1602 | mail.setPath("PATH " + getPrimaryFtnAddress().toString() + " " |
| 1603 | + (mail.getCreated().getTime() / 1000) + " " |
| 1604 | + mail.getCreated().toString() + "\r\n"); |
| 1605 | mail.setSeenby(""); |
| 1606 | String path = getFilePath(area.getName(), filename); |
| 1607 | File newFile = new File(path); |
| 1608 | if (FileUtils.move(attach, newFile, true)) { |
| 1609 | mail.setFilepath(newFile.getAbsolutePath()); |
| 1610 | } else { |
| 1611 | mail.setFilepath(attach.getAbsolutePath()); |
| 1612 | logger.l2("Failed to rename " + attach.getAbsolutePath() + " to " |
| 1613 | + path); |
| 1614 | } |
| 1615 | ORMManager.get(Filemail.class).save(mail); |
| 1616 | |
| 1617 | for (FileSubscription sub : ORMManager.get(FileSubscription.class) |
| 1618 | .getAnd("filearea_id", "=", area)) { |
| 1619 | ORMManager.get(FilemailAwaiting.class).save( |
| 1620 | new FilemailAwaiting(sub.getLink(), mail)); |
| 1621 | if (getOptionBooleanDefFalse(sub.getLink(), |
| 1622 | LinkOption.BOOLEAN_CRASH_FILEMAIL)) { |
| 1623 | PollQueue.getSelf().add(sub.getLink()); |
| 1624 | } |
| 1625 | } |
| 1626 | } |
| 1627 | |
| 1628 | public static String getFilePath(String area, String attach) { |
| 1629 | String areaPath = FtnTosser.getFileechoPath() + File.separator + area; |
no test coverage detected