~teejee2008/timeshift/trunk

« back to all changes in this revision

Viewing changes to src/Main.vala

  • Committer: Tony George
  • Date: 2013-10-24 15:11:55 UTC
  • Revision ID: teejee2008@gmail.com-20131024151155-3phu9mo26k2oflxq
Improved detection of disk partitions

Show diffs side-by-side

added added

removed removed

Lines of Context:
530
530
                }
531
531
        }
532
532
        
533
 
        public bool is_live_system(){
 
533
        public bool live_system(){
534
534
                return (root_device == null);
535
535
        }
536
536
        
1845
1845
                
1846
1846
                snapshot_list.clear();
1847
1847
 
1848
 
                if (is_snapshot_device_online() == false){ return false; }
1849
 
                
1850
1848
                string path = mount_point_backup + "/timeshift/snapshots";
1851
1849
 
1852
1850
                if (dir_exists(path)){
1890
1888
 
1891
1889
                foreach(PartitionInfo pi in partition_list){
1892
1890
                        //root_device and home_device will be detected by detect_system_devices()
1893
 
                        
1894
 
                        if (pi.mount_point == "/mnt/timeshift"){
 
1891
                        if (pi.mount_point_list.contains("/mnt/timeshift")){
1895
1892
                                snapshot_device = pi;
1896
1893
                        }
1897
1894
                        if (pi.is_mounted){
1898
 
                                pi.dist_info = DistInfo.get_dist_info(pi.mount_point).full_name();
 
1895
                                pi.dist_info = DistInfo.get_dist_info(pi.mount_point_list[0]).full_name();
1899
1896
                        }
1900
1897
                }
1901
1898
                if (partition_list.size == 0){
1936
1933
                                log_error (std_err);
1937
1934
                        }
1938
1935
                        else{
 
1936
                                string dev_root = "";
 
1937
                                string dev_home = "";
 
1938
                                
1939
1939
                                foreach(string line in std_out.split("\n")){
1940
1940
                                        if (line.contains(" / ")){
1941
 
                                                string dev = line.split(" ")[0].strip();
1942
 
                                                foreach(PartitionInfo p in partition_list){
1943
 
                                                        if (p.device == dev){
1944
 
                                                                root_device = p;
1945
 
                                                                break;
1946
 
                                                        }
1947
 
                                                }
 
1941
                                                dev_root = line.split(" ")[0].strip();
1948
1942
                                        }
1949
1943
                                        else if (line.contains(" /home ")){
1950
 
                                                string dev = line.split(" ")[0].strip();
1951
 
                                                foreach(PartitionInfo p in partition_list){
1952
 
                                                        if (p.device == dev){
1953
 
                                                                home_device = p;
1954
 
                                                                break;
1955
 
                                                        }
1956
 
                                                }
 
1944
                                                dev_home = line.split(" ")[0].strip();
 
1945
                                        }
 
1946
                                }
 
1947
                                
 
1948
                                foreach(PartitionInfo p in partition_list){
 
1949
                                        if (p.device == dev_root){
 
1950
                                                root_device = p;
 
1951
                                                break;
 
1952
                                        }
 
1953
                                }
 
1954
                                
 
1955
                                foreach(PartitionInfo p in partition_list){
 
1956
                                        if (p.device == dev_home){
 
1957
                                                home_device = p;
 
1958
                                                break;
1957
1959
                                        }
1958
1960
                                }
1959
1961
                        }
2105
2107
                string std_err;
2106
2108
                int ret_val;
2107
2109
                
2108
 
                if (is_live_system()) { return false; }
 
2110
                if (live_system()) { return false; }
2109
2111
                
2110
2112
                try{
2111
2113
                        string temp_file = get_temp_file_path();
2152
2154
        
2153
2155
        
2154
2156
        public PartitionInfo? get_backup_device(){
2155
 
                var list = get_mounted_partitions();
 
2157
                var list = get_mounted_partitions_using_df();
2156
2158
                foreach(PartitionInfo info in list){
2157
 
                        if (info.mount_point == "/mnt/timeshift"){
 
2159
                        if (info.mount_point_list.contains("/mnt/timeshift")){
2158
2160
                                return info;
2159
2161
                        }
2160
2162
                }
2176
2178
                message = "%s ".printf(snapshot_device.free) + _("free");
2177
2179
                message = message.strip();
2178
2180
                        
2179
 
                if (!is_live_system()){
2180
 
                        if (is_snapshot_device_online() == false){
 
2181
                if (!live_system()){
 
2182
                        if (!backup_device_online()){
2181
2183
                                message = _("Backup device not available!");
2182
2184
                                status_code = -1;
2183
2185
                        }
2213
2215
                return is_supported;
2214
2216
        }
2215
2217
        
2216
 
        public bool is_snapshot_device_online(){
 
2218
        public bool backup_device_online(){
2217
2219
                //check if mounted
2218
 
                foreach(PartitionInfo info in get_mounted_partitions()){
2219
 
                        if (info.mount_point == mount_point_backup){
 
2220
                foreach(PartitionInfo info in get_mounted_partitions_using_df()){
 
2221
                        if (info.mount_point_list.contains(mount_point_backup)){
2220
2222
                                return true;
2221
2223
                        }
2222
2224
                }
2224
2226
                return false;
2225
2227
        }
2226
2228
 
2227
 
 
2228
2229
        public long calculate_size_of_first_snapshot(){
2229
2230
                
2230
2231
                if (this.first_snapshot_size > 0){
2231
2232
                        return this.first_snapshot_size;
2232
2233
                }
2233
 
                else if (is_live_system()){
 
2234
                else if (live_system()){
2234
2235
                        return 0;
2235
2236
                }
2236
2237